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

getting timestamp in CI/CD

zamek z April 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
Tom Bradshaw
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 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 April 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
TAGS
AUG Leaders

Atlassian Community Events