Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add datetime to custom VERSION_LABEL in pipeline pipes

Sascha Liebau January 24, 2019

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
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 4, 2019

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

Sascha Liebau February 4, 2019

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

Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 5, 2019

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.

Sascha Liebau March 18, 2019

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
AUG Leaders

Atlassian Community Events