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

Allow common tags to be used by pipelines and global listener

    • 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
              }
            }
          }
        }
      }
      

          [JENKINS-62753] Allow common tags to be used by pipelines and global listener

          Alexandre Gaudreault created issue -
          Alexandre Gaudreault made changes -
          Description Original: 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.
          New: 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.

          [code]
          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 "ec2-fleet" as String }

            stages {
              stage ("Run") {
                steps {
                  script {
                      env.INFLUXDB_PLUGIN_PARAM_TAG = 'custom_tag=${MY_TAG_VALUE}'
                      env.INFLUXDB_PLUGIN_PARAM_VALUE = "custom_value=${MY_FIELD_VALUE}" // It can also work with string interpolation
                  }
                }
              }
            }
          }
          [code]
          Alexandre Gaudreault made changes -
          Description Original: 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.

          [code]
          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 "ec2-fleet" as String }

            stages {
              stage ("Run") {
                steps {
                  script {
                      env.INFLUXDB_PLUGIN_PARAM_TAG = 'custom_tag=${MY_TAG_VALUE}'
                      env.INFLUXDB_PLUGIN_PARAM_VALUE = "custom_value=${MY_FIELD_VALUE}" // It can also work with string interpolation
                  }
                }
              }
            }
          }
          [code]
          New: 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.

          {code}
          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 "ec2-fleet" as String }

            stages {
              stage ("Run") {
                steps {
                  script {
                      env.INFLUXDB_PLUGIN_PARAM_TAG = 'custom_tag=${MY_TAG_VALUE}'
                      env.INFLUXDB_PLUGIN_PARAM_VALUE = "custom_value=${MY_FIELD_VALUE}" // It can also work with string interpolation
                  }
                }
              }
            }
          }
          {code}
          Alexandre Gaudreault made changes -
          Link New: This issue is related to JENKINS-54445 [ JENKINS-54445 ]
          Alexandre Gaudreault made changes -
          Summary Original: Allow common tags to be used by global listener New: Allow common tags to be used by pipelines and global listener
          Alexandre Gaudreault made changes -
          Description Original: 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.

          {code}
          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 "ec2-fleet" as String }

            stages {
              stage ("Run") {
                steps {
                  script {
                      env.INFLUXDB_PLUGIN_PARAM_TAG = 'custom_tag=${MY_TAG_VALUE}'
                      env.INFLUXDB_PLUGIN_PARAM_VALUE = "custom_value=${MY_FIELD_VALUE}" // It can also work with string interpolation
                  }
                }
              }
            }
          }
          {code}
          New: 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.

          {code}
          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
                  }
                }
              }
            }
          }
          {code}
          Alexandre Gaudreault made changes -
          Remote Link New: This issue links to "Github Pull Request #105 (Web Link)" [ 25713 ]
          Alexandre Gaudreault made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Alexandre Gaudreault made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          Aleksi Simell added a comment -

          PR merged. Will be available in next release.

          Aleksi Simell added a comment - PR merged. Will be available in next release.
          Aleksi Simell made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Fixed but Unreleased [ 10203 ]

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

              Created:
              Updated:
              Resolved: