简化此 bitbucket 管道的选项
Option to simplify this bitbucket pipeline
我创建了一个 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
使用不同的 Docker 图片。您当前使用的 (samueldebruyn/debian-git
) 不包括 git-ftp,但如果您使用其他人制作的(检查 hub.docker.com)或制作一个你自己然后你将在管道的开始处拥有该实用程序。这将为您节省管道中的步骤,并节省时间。
我创建了一个 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
使用不同的 Docker 图片。您当前使用的 (samueldebruyn/debian-git
) 不包括 git-ftp,但如果您使用其他人制作的(检查 hub.docker.com)或制作一个你自己然后你将在管道的开始处拥有该实用程序。这将为您节省管道中的步骤,并节省时间。