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

Checkout in second stage sets SUCCESS on Github commit

    Details

    • Similar Issues:

      Description

      In a multi-agent pipeline, 'checkout' step sets SUCCESS status to Github commit. This happens if any previous stage already published successful build result.

      So commit is marked as SUCCESS for some time. If later tests fail, commit status is changed for FAILURE. This enables bad code merge from a PR and bad code deployment.

      This is seen in several complex pipelines with the both pipeline default checkout and with checkout scm. Here is a minimal example, where junit or any other publishing step replaced with currentBuild.result = 'SUCCESS':

      pipeline {
          agent none
      
          stages {
              stage('Set SUCCESS') {
                  agent any
                  steps {
                      script {
                          currentBuild.result = 'SUCCESS'
                      }
                  }
              }
              stage('Checkout, test, fail') {
                  agent any
                  steps {
                      sh """sleep 60
                            exit 1"""
                  }
              }
          }
      }
      

      Here are selected lines rom a build log. Note two 'GitHub has been notified' messages:

      Branch indexing
      06:33:50 Connecting to https://api.github.com using ****
      Obtained Jenkinsfile from 2c5c8ce94a1ba597eab4c959a4f43f505c38a77c
      [Pipeline] stage
      [Pipeline] { (Set SUCCESS)
      [Pipeline] node
      Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
      [Pipeline] {
      [Pipeline] checkout
      ...<log cut>
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] script
      [Pipeline] {
      [Pipeline] }
      [Pipeline] // script
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Checkout, test, fail)
      [Pipeline] node
      Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
      [Pipeline] {
      [Pipeline] checkout
       > /usr/bin/git rev-parse --is-inside-work-tree # timeout=60
      Fetching changes from the remote Git repository
      ...<log cut>
       > /usr/bin/git config core.sparsecheckout # timeout=60
       > /usr/bin/git checkout -f 7ce1f7ba4b355294f3fc475b9d84528eba3669cb
      Commit message: "Update Jenkinsfile"
      
      GitHub has been notified of this commit’s build result
      
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] sh
      [a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA] Running shell script
      + sleep 60
      + exit 1
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      
      GitHub has been notified of this commit’s build result
      
      ERROR: script returned exit code 1
      Finished: FAILURE
      

        Attachments

          Issue Links

            Activity

            vorobievalex Alexander Vorobiev created issue -
            Hide
            vorobievalex Alexander Vorobiev added a comment -

            Could this have an attention? This makes all the pipeline stages features unusable and blocks further implementation of any.

            Show
            vorobievalex Alexander Vorobiev added a comment - Could this have an attention? This makes all the pipeline stages features unusable and blocks further implementation of any.
            vorobievalex Alexander Vorobiev made changes -
            Field Original Value New Value
            Component/s core [ 15593 ]
            Hide
            stevenfoster Steven Foster added a comment -

            do you have https://plugins.jenkins.io/github-autostatus plugin installed?

            Show
            stevenfoster Steven Foster added a comment - do you have https://plugins.jenkins.io/github-autostatus plugin installed?
            Hide
            vorobievalex Alexander Vorobiev added a comment -

            Steven Foster, no, this plugin is not installed in the system.

            Thank you for looking at it.

            Show
            vorobievalex Alexander Vorobiev added a comment - Steven Foster , no, this plugin is not installed in the system. Thank you for looking at it.
            Hide
            stevenfoster Steven Foster added a comment -

            From what I understand, the Multibranch (github-branch-source) pipeline only updates the Github Commit Status at 3 places:

            When the job is queued (pending)
            When the repo is checked out (in progress)
            and When the job finishes (result)

            I'm not sure where it would update the commit status in the middle of the build, that's why I asked about another plugin.

            Show
            stevenfoster Steven Foster added a comment - From what I understand, the Multibranch (github-branch-source) pipeline only updates the Github Commit Status at 3 places: When the job is queued (pending) When the repo is checked out (in progress) and When the job finishes (result) I'm not sure where it would update the commit status in the middle of the build, that's why I asked about another plugin.
            Hide
            stevenfoster Steven Foster added a comment -

            Actually, I see the bug now. My mistake. I'll try to fix it

            Show
            stevenfoster Steven Foster added a comment - Actually, I see the bug now. My mistake. I'll try to fix it
            Hide
            vorobievalex Alexander Vorobiev added a comment -

            Awesome! Looking forward to be able to split our monolith stages.

            Show
            vorobievalex Alexander Vorobiev added a comment - Awesome! Looking forward to be able to split our monolith stages.
            frankgrimes97 Frank Grimes made changes -
            Description In a multi-agent pipeline, 'checkout' step sets SUCCESS status to Github commit. This happens if any previous stage already published successful build result.

            So commit is marked as SUCCESS for some time. If later tests fail, commit status is changed for FAILURE. *This enables bad code merge from a PR and bad code deployment*.

            This is seen in several complex pipelines with the both pipeline default checkout and with {{checkout scm}}. Here is a minimal example, where {{junit}} or any other publishing step replaced with {{currentBuild.result = 'SUCCESS'}}:
            {code:java}
            pipeline {
                agent none

                stages {
                    stage('Set SUCCESS') {
                        agent any
                        steps {
                            script {
                                currentBuild.result = 'SUCCESS'
                            }
                        }
                    }
                    stage('Checkout, test, fail') {
                        agent any
                        steps {
                            sh """sleep 60
                                  exit 1"""
                        }
                    }
                }
            }
            {code}
            Here are selected lines rom a build log. Note two 'GitHub has been notified' messages:
            {code:java}
            Branch indexing
            06:33:50 Connecting to https://api.github.com using ****
            Obtained Jenkinsfile from 2c5c8ce94a1ba597eab4c959a4f43f505c38a77c
            [Pipeline] stage
            [Pipeline] { (Set SUCCESS)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
            ...<log cut>
            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] script
            [Pipeline] {
            [Pipeline] }
            [Pipeline] // script
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] stage
            [Pipeline] { (Checkout, test, fail)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
             > /usr/bin/git rev-parse --is-inside-work-tree # timeout=60
            Fetching changes from the remote Git repository
            ...<log cut>
             > /usr/bin/git config core.sparsecheckout # timeout=60
             > /usr/bin/git checkout -f 7ce1f7ba4b355294f3fc475b9d84528eba3669cb
            Commit message: "Update Jenkinsfile"

            GitHub has been notified of this commit’s build result

            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] sh
            [a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA] Running shell script
            + sleep 60
            + exit 1
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] End of Pipeline

            GitHub has been notified of this commit’s build result

            ERROR: script returned exit code 1
            Finished: FAILURE
            {code}
            tIn a multi-agent pipeline, 'checkout' step sets SUCCESS status to Github commit. This happens if any previous stage already published successful build result.

            So commit is marked as SUCCESS for some time. If later tests fail, commit status is changed for FAILURE. *This enables bad code merge from a PR and bad code deployment*.

            This is seen in several complex pipelines with the both pipeline default checkout and with {{checkout scm}}. Here is a minimal example, where {{junit}} or any other publishing step replaced with {{currentBuild.result = 'SUCCESS'}}:
            {code:java}
            pipeline {
                agent none

                stages {
                    stage('Set SUCCESS') {
                        agent any
                        steps {
                            script {
                                currentBuild.result = 'SUCCESS'
                            }
                        }
                    }
                    stage('Checkout, test, fail') {
                        agent any
                        steps {
                            sh """sleep 60
                                  exit 1"""
                        }
                    }
                }
            }
            {code}
            Here are selected lines rom a build log. Note two 'GitHub has been notified' messages:
            {code:java}
            Branch indexing
            06:33:50 Connecting to https://api.github.com using ****
            Obtained Jenkinsfile from 2c5c8ce94a1ba597eab4c959a4f43f505c38a77c
            [Pipeline] stage
            [Pipeline] { (Set SUCCESS)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
            ...<log cut>
            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] script
            [Pipeline] {
            [Pipeline] }
            [Pipeline] // script
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] stage
            [Pipeline] { (Checkout, test, fail)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
             > /usr/bin/git rev-parse --is-inside-work-tree # timeout=60
            Fetching changes from the remote Git repository
            ...<log cut>
             > /usr/bin/git config core.sparsecheckout # timeout=60
             > /usr/bin/git checkout -f 7ce1f7ba4b355294f3fc475b9d84528eba3669cb
            Commit message: "Update Jenkinsfile"

            GitHub has been notified of this commit’s build result

            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] sh
            [a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA] Running shell script
            + sleep 60
            + exit 1
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] End of Pipeline

            GitHub has been notified of this commit’s build result

            ERROR: script returned exit code 1
            Finished: FAILURE
            {code}
            frankgrimes97 Frank Grimes made changes -
            Description tIn a multi-agent pipeline, 'checkout' step sets SUCCESS status to Github commit. This happens if any previous stage already published successful build result.

            So commit is marked as SUCCESS for some time. If later tests fail, commit status is changed for FAILURE. *This enables bad code merge from a PR and bad code deployment*.

            This is seen in several complex pipelines with the both pipeline default checkout and with {{checkout scm}}. Here is a minimal example, where {{junit}} or any other publishing step replaced with {{currentBuild.result = 'SUCCESS'}}:
            {code:java}
            pipeline {
                agent none

                stages {
                    stage('Set SUCCESS') {
                        agent any
                        steps {
                            script {
                                currentBuild.result = 'SUCCESS'
                            }
                        }
                    }
                    stage('Checkout, test, fail') {
                        agent any
                        steps {
                            sh """sleep 60
                                  exit 1"""
                        }
                    }
                }
            }
            {code}
            Here are selected lines rom a build log. Note two 'GitHub has been notified' messages:
            {code:java}
            Branch indexing
            06:33:50 Connecting to https://api.github.com using ****
            Obtained Jenkinsfile from 2c5c8ce94a1ba597eab4c959a4f43f505c38a77c
            [Pipeline] stage
            [Pipeline] { (Set SUCCESS)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
            ...<log cut>
            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] script
            [Pipeline] {
            [Pipeline] }
            [Pipeline] // script
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] stage
            [Pipeline] { (Checkout, test, fail)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
             > /usr/bin/git rev-parse --is-inside-work-tree # timeout=60
            Fetching changes from the remote Git repository
            ...<log cut>
             > /usr/bin/git config core.sparsecheckout # timeout=60
             > /usr/bin/git checkout -f 7ce1f7ba4b355294f3fc475b9d84528eba3669cb
            Commit message: "Update Jenkinsfile"

            GitHub has been notified of this commit’s build result

            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] sh
            [a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA] Running shell script
            + sleep 60
            + exit 1
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] End of Pipeline

            GitHub has been notified of this commit’s build result

            ERROR: script returned exit code 1
            Finished: FAILURE
            {code}
            In a multi-agent pipeline, 'checkout' step sets SUCCESS status to Github commit. This happens if any previous stage already published successful build result.

            So commit is marked as SUCCESS for some time. If later tests fail, commit status is changed for FAILURE. *This enables bad code merge from a PR and bad code deployment*.

            This is seen in several complex pipelines with the both pipeline default checkout and with {{checkout scm}}. Here is a minimal example, where {{junit}} or any other publishing step replaced with {{currentBuild.result = 'SUCCESS'}}:
            {code:java}
            pipeline {
                agent none

                stages {
                    stage('Set SUCCESS') {
                        agent any
                        steps {
                            script {
                                currentBuild.result = 'SUCCESS'
                            }
                        }
                    }
                    stage('Checkout, test, fail') {
                        agent any
                        steps {
                            sh """sleep 60
                                  exit 1"""
                        }
                    }
                }
            }
            {code}
            Here are selected lines rom a build log. Note two 'GitHub has been notified' messages:
            {code:java}
            Branch indexing
            06:33:50 Connecting to https://api.github.com using ****
            Obtained Jenkinsfile from 2c5c8ce94a1ba597eab4c959a4f43f505c38a77c
            [Pipeline] stage
            [Pipeline] { (Set SUCCESS)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
            ...<log cut>
            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] script
            [Pipeline] {
            [Pipeline] }
            [Pipeline] // script
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] stage
            [Pipeline] { (Checkout, test, fail)
            [Pipeline] node
            Running on master in /Home/workspace/a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA
            [Pipeline] {
            [Pipeline] checkout
             > /usr/bin/git rev-parse --is-inside-work-tree # timeout=60
            Fetching changes from the remote Git repository
            ...<log cut>
             > /usr/bin/git config core.sparsecheckout # timeout=60
             > /usr/bin/git checkout -f 7ce1f7ba4b355294f3fc475b9d84528eba3669cb
            Commit message: "Update Jenkinsfile"

            GitHub has been notified of this commit’s build result

            [Pipeline] withEnv
            [Pipeline] {
            [Pipeline] sh
            [a_a_a-NZHSOOK6DLZNS5KEQNGRGFRRYDRS74EJJG6PZYDHEPRJUQRTRCDA] Running shell script
            + sleep 60
            + exit 1
            [Pipeline] }
            [Pipeline] // withEnv
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] End of Pipeline

            GitHub has been notified of this commit’s build result

            ERROR: script returned exit code 1
            Finished: FAILURE
            {code}
            abayer Andrew Bayer made changes -
            Component/s core [ 15593 ]
            Hide
            timja Tim Jacomb added a comment -

            Steven Foster Did you get anywhere with this?

            Show
            timja Tim Jacomb added a comment - Steven Foster Did you get anywhere with this?
            Show
            stevenfoster Steven Foster added a comment - I have an open PR at  https://github.com/jenkinsci/github-branch-source-plugin/pull/175
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Stephen Connolly
            Path:
            src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java
            http://jenkins-ci.org/commit/github-branch-source-plugin/23480ace348f5515e227e507d5aeeda46fc93c89
            Log:
            Merge pull request #175 from steven-foster/JENKINS-47366

            JENKINS-47366 Avoid reporting premature build status

            Compare: https://github.com/jenkinsci/github-branch-source-plugin/compare/c088f0b60bf9...23480ace348f
            *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

            Functionality will be removed from GitHub.com on January 31st, 2019.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java http://jenkins-ci.org/commit/github-branch-source-plugin/23480ace348f5515e227e507d5aeeda46fc93c89 Log: Merge pull request #175 from steven-foster/ JENKINS-47366 JENKINS-47366 Avoid reporting premature build status Compare: https://github.com/jenkinsci/github-branch-source-plugin/compare/c088f0b60bf9...23480ace348f * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.
            rsandell rsandell made changes -
            Remote Link This issue links to "Page (Jenkins Wiki)" [ 20796 ]
            vorobievalex Alexander Vorobiev made changes -
            Assignee Steven Foster [ stevenfoster ]
            Hide
            vorobievalex Alexander Vorobiev added a comment -

            Works fine now. Thanks a lot!

            Show
            vorobievalex Alexander Vorobiev added a comment - Works fine now. Thanks a lot!
            vorobievalex Alexander Vorobiev made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            vorobievalex Alexander Vorobiev made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Assignee:
                stevenfoster Steven Foster
                Reporter:
                vorobievalex Alexander Vorobiev
              • Votes:
                3 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: