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

Pipeline : Generate a unique name for each pipeline

James St-Pierre July 12, 2019

In our BitBucket Pipeline we must provide a variable to `pipe: atlassian/aws-elasticbeanstalk-deploy:0.3.0` that must be unique everytime.

 

What we are currently using :

- step:
name: Deploy to AWS
deployment: production-aws
image: atlassian/default-image:2
script:
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.3.0
variables:
...
VERSION_LABEL: "name.$BITBUCKET_BUILD_NUMBER-bitbucket"

 

We currently have an issue : if the step fails and we use "Retry only failed steps", the $BITBUCKET_BUILD_NUMBER is not incremented. This is causing an error on our end because the "VERSION_LABEL" is already in use.

 

Is there another way to generate a unique version label?

 

Thank you !

1 answer

1 accepted

1 vote
Answer accepted
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2019

Hi @James St-Pierre

I'm not sure if there is an easy way to identify if a build is rerun in pipelines, but what you could use in your label is a Linux timestamp. You could create a variable and use it in your label to distinguish builds based on the time the ran.

This would be the way to create the variable

script:
- TIMESTAMP=`date +%s`
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.3.0
variables:
...
VERSION_LABEL: "name.$BITBUCKET_BUILD_NUMBER-$TIMESTAMP-bitbucket"

I hope that is a possible solution for this issue.

James St-Pierre July 17, 2019

Thank you ! This solution is perfect

Like Daniel Santos likes this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2019

Awesome! I'm glad that helps!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events