Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Get context of a deploying step "Redeploying"


Is it possible to determine if the step is performing a regular deployment or a redeployment?

I need this context to be able to perform custom functionality if the step is redeploying instead of just a regular deploy.

Checking all the environment variables, Bitbucket doesn't seem to expose anything. Best I think I could do is check the current build number or commit hash and determine if it's a redeploy based on that.

1 answer

1 accepted

1 vote
Answer accepted
Patrik S Atlassian Team Sep 08, 2022

Hey @Alan Dragicevich ,

Thank you for reaching out to Atlassian Community!

I'm afraid there's currently no direct way of identifying if a given step is a re-deployment. I do understand how this feature could benefit your use case to build custom logic based on this information, so I went ahead and created a feature request to include an environment variable that exposes if the step is a normal deploy or a re-deploy : 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.

While this feature is not implemented, one of the workarounds would be for you to manually check within your step's script if the commit being deployed is the same commit that is already currently in the target deployment environment, which would confirm it's a re-deploy.

Let me know if you have any questions.

Thank you, @Alan Dragicevich .

Kind regards,

Patrik S

For you workaround solution, would I need to use the Bitbucket API for this?

I will give it a go.

Thanks heaps!

Patrik S Atlassian Team Sep 13, 2022

Hey @Alan Dragicevich .

To get the commit currently running in the pipeline, you can use the default environment variable BITBUCKET_COMMIT.

As for the commit currently deployed to the destination environment, you would have to implement this manually, for example, by saving a file in the destination server with the last commit deployed, and checking for that file every time you do a new deploy to confirm if the commit is the same (which would configure a re-deploy) or different.

Thank you, @Alan Dragicevich .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,490 views 3 10
Read article

Atlassian Community Events