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

Influx build_result is not set correct if written in post section

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • influxdb-plugin
    • None

      I never get a 'SUCCESS' in the `build_result` field if data is reported to Influx in a pipeline `post` section.
      I would expect that at this time, the outcome is of the pipeline run is set.

      pipeline{
        stages {
          stage('A') {
            steps {
              echo "build result: ${currentBuild.result}"
              echo "current build result: ${currentBuild.currentResult}"
            }
          }
        }
        post{
          always{
            script {
              node {
                step([$class: 'InfluxDbPublisher', selectedTarget: 'myInflux'])
              }
            }
          }
        }
      }
      

          [JENKINS-56532] Influx build_result is not set correct if written in post section

          Aleksi Simell added a comment -

          This is documented in the Wiki: Pipelines don't have post-build actions, so the build result, build ordinal, and the build success boolean must be set manually. They will default to "?", 5, and false respectively unless set before calling the step. The boolean value is set according to the ordinal value and the ordinal value is fetched according to build result, so only the build result have to be set manually.

          If you add the the echo to the post action you have there `echo "post build result: ${currentBuild.result}"` you will get `post build result: null`.

          Aleksi Simell added a comment - This is documented in the Wiki : Pipelines don't have post-build actions, so the build result, build ordinal, and the build success boolean must be set manually. They will default to "?", 5, and false respectively unless set before calling the step. The boolean value is set according to the ordinal value and the ordinal value is fetched according to build result, so only the build result have to be set manually. If you add the the echo to the post action you have there `echo "post build result: ${currentBuild.result}"` you will get `post build result: null`.

          Thanks for the heads up, I solved the issue by setting the build result in the post action if it's null.
          Therefore you can close this issue.

          Christopher Fenner added a comment - Thanks for the heads up, I solved the issue by setting the build result in the post action if it's null. Therefore you can close this issue.

            aleksisimell Aleksi Simell
            ennef Christopher Fenner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: