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

Should we use result or currentResult?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pipeline
    • None
    • Jenkins ver. 2.70

      I'm having a lot of trouble properly reporting build status at the end of my declarative pipeline. I've witnessed failed builds report success in Slack and GitLab, both separately and together. For example, here's a failed build, yet it shows success in Slack for the same build.

      And another example where the build failed and, yet, it shows success in GitLab.

      I'm using a simple map of Jenkins status to Slack color / GitLab status. This helps keep my post block small & clean, since the only thing that varies is this result.

      Jenkinsfile (partial)
      def COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED', 'danger']
      def STATUS_MAP = ['SUCCESS': 'success', 'FAILURE': 'failed', 'UNSTABLE': 'failed', 'ABORTED', 'failed']
      
      ...
      
      post { 
        always { 
          slackSend channel: '#build', color: COLOR_MAP[currentBuild.currentResult], message: 'Whatever.'
          updateGitlabCommitStatus name: 'build', state: STATUS_MAP[currentBuild.currentResult]
        }
      }
      

      It's not obvious which should be used and there's a lack of documentation (short of reading the source code).

      Am I using the wrong model property or am I using it incorrectly? Clearly, Jenkins has one result and, yet, it's sending a different result to the plugins. I need a reliable result. I thought I could depend on the result in the post block, is that not true?

            Unassigned Unassigned
            anthonymastrean Anthony Mastrean
            Votes:
            10 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated: