【问题标题】:Option to simplify this bitbucket pipeline简化此 bitbucket 管道的选项
【发布时间】:2019-07-07 01:20:05
【问题描述】:

我创建了一个 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

【问题讨论】:

    标签: automation pipeline bitbucket-pipelines


    【解决方案1】:

    使用不同的 Docker 映像。您当前使用的(samueldebruyn/debian-git)不包括 git-ftp,但如果您使用其他人制作的(查看 hub.docker.com)或自己制作,那么您将在管道的开始。这将节省您在管道中的步骤,并且还可以构建几分钟。

    【讨论】:

    • 我是 debian-git 镜像的创建者,我不建议再使用它。在我创建它的时候,没有很多替代品。我没有时间维护这样的形象,所以bitname/gitalpine/git 是不错的选择。
    猜你喜欢
    • 1970-01-01
    • 2020-10-08
    • 2016-12-02
    • 2018-05-26
    • 2018-05-02
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多