Reputation: 3543
I created a bitbucket pipeline, but for every script i need to execute the same scripts:
- apt-get update
- apt-get -qq install git-ftp
But i am looking for a way to optimise and simplify this:
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
Upvotes: 0
Views: 101
Reputation: 5640
Use a different Docker image. The one you are currently using (samueldebruyn/debian-git
) doesn't include git-ftp, but if you use one that somebody else has made (check hub.docker.com) or make one yourself then you'll have that utility at the start of the pipeline. That will save you steps in the pipeline, and also build minutes.
Upvotes: 1