Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62753

Allow common tags to be used by pipelines and global listener

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor Minor
    • influxdb-plugin
    • None
    • 2.5

      Some very nice work has been done by aleksisimell in Jenkins-54445 to add tags on every metrics, but we cannot use that feature if we are using a GlobalListener like we are doing with pipelines.

      You can see in the code that null is always sent to the PublicationService.
      https://github.com/jenkinsci/influxdb-plugin/blob/development/src/main/java/jenkinsci/plugins/influxdb/global/GlobalRunListener.java#L55-L56

      It would be nice if we could somehow specify that parameter as build environment variable.

      pipeline {
        options {
          timestamps()
          skipDefaultCheckout()
        }
        
        parameters {
            string(name: 'MY_TAG_VALUE', description: 'The value of the tag', defaultValue: 'test')
            string(name: 'MY_FIELD_VALUE', description: 'The value of the field', defaultValue: '10')
        }
      
        agent { label "master" }
      
        stages {
          stage ("Run") {
            steps {
              script {
                  env.INFLUXDB_PLUGIN_CUSTOM_TAGS = 'custom_tag=${MY_TAG_VALUE}'
                  env.INFLUXDB_PLUGIN_CUSTOM_FIELDS = "custom_field=${MY_FIELD_VALUE}" // It can also work with string interpolation
              }
            }
          }
        }
      }
      

            aleksisimell Aleksi Simell
            agaudreault Alexandre Gaudreault
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: