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

getting timestamp in CI/CD

zamek z Apr 12, 2019

Hi All,

I need to get the current timestamp in a CI/CD pipeline script (yml). I tried to do it like this:

        - buildtimestamp=$(date +%N)     
        - echo $buildtimestamp                                                                                                  
         - mvn -s maven_settings.xml -Dbuild_timestamp=$buildtimestamp -DskipTests=true -Ddocker_registry=$docker_registry_dev -P docker docker:build

I have a couple of projects, some projects working well, but there are three projects, which print an empty string. I tried to use - export buildtimestamp=$(date +%N), but it didn't help. 

Is there any other method to get the current timestamp?

thx

Zamek

1 answer

0 votes
Thomas Bradshaw Atlassian Team Apr 15, 2019

Hi @zamek z

Can you add `echo $(date +%N)` (or whatever the buildtimestamp operation is) to those projects that are failing to confirm that the operation can be successfully called.

Cheers,

Tom

zamek z Apr 16, 2019

Hi Thomas,

 

Yes I added like this:

- buildtimestamp=$(date +%N)     
- echo $buildtimestamp                                                                                                  
- mvn -s maven_settings.xml -Dbuild_timestamp=$buildtimestamp -DskipTests=true -Ddocker_registry=$docker_registry_dev -P docker docker:build

Nowaday I changed %+N to %+s which is the epoch time (N means nanoseconds only). Since I changed to %+s there was no problem.

thx,

Zamek

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,652 views 1 18
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