我创建了一个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发布于 2019-02-14 08:24:53
使用不同的Docker镜像。你当前使用的工具(samueldebruyn/debian-git)不包含git-ftp,但是如果你使用别人做的工具(查看hub.docker.com)或者你自己做的工具,那么你将在管道的开始部分拥有这个工具。这将为您节省流水线中的步骤,还可以节省构建时间。
https://stackoverflow.com/questions/54666274
复制相似问题