0

I am trying to create a custom Environment variables in Jenkins by doing this

List of key-value pairs

Name: Build_Date Value: Date()

The value part is not resolving to a date - any ideas?

Here is where I am trying to config the above

enter image description here

Thanks

Michael Gill
  • 153
  • 2
  • 6

1 Answers1

3

I confirm that you can use the EnvInject plugin with a Groovy script:

enter image description here

Here is the Groovy script:

// Generate a global BUILD_ID_LONG variable with date and time
// =======================================

TimeZone.setDefault(TimeZone.getTimeZone('UTC'))
def now = new Date()
def map = [BUILD_ID_LONG: now.format("yyyyMMdd_HHmm")]
return map

Next, you can use the ${BUILD_ID_LONG} variable in your build steps.

Bruno Lavit
  • 10,184
  • 2
  • 32
  • 38