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}"
Y
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.