Skip to content

Add ability to customize build tags from groovy pipelines #22

Description

@gzussa

Migrated from DataDog/jenkins-datadog-plugin#115

Description

I need to change a tag value based on what triggered the build (i.e. what's the build cause). After a lot of tinkering, I'm doing something like this:

def cause = 'something' // actually comes from currentBuild.rawBuild.getCause...
properties([
  [
    $class: 'DatadogJobProperty',
    tagProperties: "cause=${cause}"
  ]
])

And this sort of works, but isn't really reliable. It causes issues when multiple jobs run concurrently. The current DatadogJobProperty value is used whenever a build finishes. That means that if job A starts with cause "A" and job B starts with cause "B" before A finishes running, then both jobs will use the last DatadogJobProperty which has "B" configured as the cause.

I also tried the following, but this fails to set the value altogether. The tag ends up as cause=_cause.

env.CAUSE = 'something' // actually comes from currentBuild.rawBuild.getCause...
properties([
  [
    $class: 'DatadogJobProperty',
    tagProperties: 'cause=${CAUSE}'
  ]
])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions