简化此位桶流水线的选项

时间:2019-02-13 09:07:05

标签: automation pipeline bitbucket-pipelines

我创建了一个Bitbucket管道,但是对于每个脚本,我需要执行相同的脚本:

- apt-get update
- apt-get -qq install git-ftp

但是我正在寻找一种优化和简化此方法的方法:

image: samueldebruyn/debian-git
pipelines:
    custom: # Pipelines that are triggered manually via the Bitbucket GUI
        init-staging:
            - step:
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp init --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$STAGING_FTP_URL" -v
        init-production:
            - step:
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp init --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$PRODUCTION_FTP_URL" -v
        re-deploy-all-to-staging: # -- Deploys all files from the selected commit
            - step:
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp init --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$STAGING_FTP_URL" -v --all
        re-deploy-all-to-production: # -- Deploys all files from the selected commit
            - step:
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp init --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$PRODUCTION_FTP_URL" -v --all
        manual-to-staging:
            - step:
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp push --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$STAGING_FTP_URL" -v
        manual-to-production:
            - step:
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp push --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$PRODUCTION_FTP_URL" -v
    branches: # Automated triggers on commits to branches
        master: # When committing to master branch
            - step:
                deployment: staging
                script:
                    - apt-get update
                    - apt-get -qq install git-ftp
                    - git ftp push --user "$FTP_USERNAME" --passwd "$FTP_PASSWORD" "$STAGING_FTP_URL" -v

1 个答案:

答案 0 :(得分:1)

使用其他Docker映像。您当前正在使用的(error[E0106]: missing lifetime specifier --> src/main.rs:10:14 | 10 | fn test() -> B { | ^ help: consider giving it a 'static lifetime: `B + 'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from )不包括git-ftp,但是如果您使用别人制作的一个(请检查hub.docker.com)或自己制作一个,则将拥有该实用程序在管道的开始。这样可以节省您的准备步骤,并节省几分钟的时间。