Getting current timestamp in inline pipeline script using pipeline plugin of hudson

前端 未结 5 884
天命终不由人
天命终不由人 2021-01-01 17:02

I want to get Getting current timestamp in inline pipeline script using pipeline plugin of hudson. For setting up build display name.

Inline groovy script used:

5条回答
  •  无人及你
    2021-01-01 17:58

    Just format the Date object:

    stage('Foo') {
      steps {
        script {
            def now = new Date()
            println now.format("yyMMdd.HHmm", TimeZone.getTimeZone('UTC'))
        }
      } 
    }
    

提交回复
热议问题