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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

deploy in-pipeline-commits as well

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

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
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,326 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you