Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

deploy in-pipeline-commits as well

SVB Technik October 30, 2020

hi there!

imagine there is a step within your pipeline that commits something back into the repository as described here: https://support.atlassian.com/bitbucket-cloud/docs/push-back-to-your-repository/.

The same pipeline contains a deployment step as well, so first we add a new commit in Step A and then deploy our code to production on step B. How do I tell the deployment step B to deploy not only the commit the current pipeline is running for but also the dynamically added commit that has been added in Step A?

My workaround for this would probably be disabling automatic cloning, adding a repository variable for git repo access and manually cloning the latest commit in the current branch... but I wonder if there is a cleaner way to reach that goal.

 

Here's a little example pipeline config, maybe it's easier to understand the issue like that:

pipelines:
default:
- step:
script:
- echo "Made a change in build ${BITBUCKET_BUILD_NUMBER}" >> changes.txt
- git add changes.txt
- git commit -m "[skip ci] Updating changes.txt with latest build number."
- git push
- step:
deployment: production
script:
# this will not deploy the commit from step one, just the current pipeline commit.
- rsync -avh . root@production:/var/application/

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 4, 2020

Hello,

In this example yml file you attached here, what you need to do is add

- git pull

before the command that deploys, in the second step.

For every step in a Pipelines build, a Docker container starts, the repo is cloned in that container and HEAD is set at the commit the Pipelines build is running for.

Let's say that a build runs on commit 9f28cbd. The first step creates another commit, e.g. f464f1f and pushes it to the repo.

Afterwards, for the second step, another Docker container starts, the repo is cloned again and HEAD is also set at 9f28cbd, as this is the commit the build is running for.

If you want the new commit you added to the previous step, you can do a git pull to fetch that commit in the clone of the second step.

Is this something that works for you?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events