Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to add datetime to custom VERSION_LABEL in pipeline pipes Edited

How can I let pipelines resolve the current datetime for a VERSION_LABEL?

Cuurentlly I have this but its only adding the string "YYY-mm-dd_HHMMSS" to my resulting version tag:

 

VERSION_LABEL: "${APPLICATION_ENVIRONMENT}_YYYY-mm-dd_HHMMSS_${BITBUCKET_BUILD_NUMBER}"

1 answer

0 votes

Hi Sascha,

Just to confirm (I'm assume from the syntax), this is for a Pipe?

Pipelines supports environment variables as parameters for pipes. You should be able to use variables with the following configuration:

VERSION_LABEL: $APPLICATION_ENVIRONMENT"_YYYY-mm-dd_HHMMSS_"$BITBUCKET_BUILD_NUMBER

Thanks,

Phil

Hi Phil,

 

thanks for your response. Yes your are right: I am talking about Pipes.

Unfortunately that doesnt work. Tested it right ahead and its still not resolving the date time pattern. It does resolve the env variables though (as expected). With the configuration you suggested I get this result (again):

"VersionLabel": "myresolvedappenvname_YYYY-mm-dd_HHMMSS_109",

Seems Pipes is not capable of resolving those patterns yet.

Sascha

Oh sorry, I misinterpreted what you wanted.

The value you provide here is passed into a Docker shell command, so standard Bash string substitution should work here.

e.g.

See LOCAL_PATH. It will be set as "hello-world"

pipelines:
default:
- step:
script:
- mkdir hello-world
- pipe: atlassian/aws-s3-deploy:0.2.1
variables:
AWS_ACCESS_KEY_ID: $ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: "us-east-1"
S3_BUCKET: "my-bucket-name"
LOCAL_PATH: '$(echo "hello-world")' # This line here.

You should be able to get what you want with roughly:

VERSION_LABEL: '$APPLICATION_ENVIRONMENT"_"$(date +%Y%m%d_%H%M%S)"_"$BITBUCKET_BUILD_NUMBER'

Obviously it's not the nicest looking config, so you could instead create the variable like this:

pipelines:
default:
- step:
script:
- export LABEL=$APPLICATION_ENVIRONMENT"_"$(date +%Y%m%d_%H%M%S)"_"$BITBUCKET_BUILD_NUMBER
- pipe:
...
VERSION_LABEL: $LABEL

Or something along those lines. There might be some syntax errors in those examples. But hopefully you see what I mean.

Hi Phil.

Thanks for your response. It works. finally ended up with this:

 

- step:
name: Development EB-Deplyoment
deployment: test
script:
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.1
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
APPLICATION_NAME: $APPLICATION_NAME
VERSION_LABEL: $APPLICATION_ENVIRONMENT_$(date +%Y-%m-%d_%H:%M:%S)_$BITBUCKET_BUILD_NUMBER
ENVIRONMENT_NAME: $APPLICATION_ENVIRONMENT
ZIP_FILE: "artifact.zip"
Like Deleted user likes this

Suggest an answer

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

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

518 views 10 8
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