Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Timezone parameter for evaluations #78

Open
pcjeffmac opened this issue Dec 14, 2021 · 1 comment
Open

Add Timezone parameter for evaluations #78

pcjeffmac opened this issue Dec 14, 2021 · 1 comment

Comments

@pcjeffmac
Copy link
Contributor

Feature Request

Need to pass in the timezone to allow timezones to match customers configuration with jenkins and keptn.

References

These features need a timezone,

markEvaluationStartTime()
sendStartEvaluationEvent()

If you think about adding a timezone option to the getNow.

def defineTZVariable(timezone) {
    if (timezone == null || timezone == "") {
      // use to set default timezone
      timezone = "UTC"     
    } else {
   	  timezone = timezone
    }
    def zid = ZoneId.of(timezone)
    echo "ZID: ${zid}"
    return zid
}

Then something like this,

def getNow() {
    // get timezone.
    def keptnInit = keptnLoadFromInit(args)
    String timezone = keptnInit['timezone']
    zid = defineTZVariable(timezone)
    // return java.time.LocalDateTime.now() 
    return java.time.Instant.now(zid)
}

You can also see this to use a timezone parameter,

def markEvaluationStartTime(timezone) {
    // get timezone.     
    zid = defineTZVariable(timezone)
    //def startTime = getNow().toString()       
    def LocalDateTime starttimelocal = LocalDateTime.now(zid)       
    // format time
    startTime = timestampFormatter(starttimelocal)

This in turn is basically adding a timezone to the timeformatter.

Thanks,
Jeff

@christian-kreuzberger-dtx
Copy link
Contributor

Hi,

as far as I understand, getNow (which is currently implemented as return java.time.Instant.now().truncatedTo( ChronoUnit.MILLIS )) always returns the time in UTC, which is what Keptn accepts and uses by default.

What is the benefit of matching the timezone of the Jenkins installation, other than having the same string representation of the date time object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants