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

Get context of a deploying step "Redeploying"

Alan Dragicevich
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 6, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
September 8, 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

Alan Dragicevich
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 8, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
September 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
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events