-
Bug
-
Resolution: Fixed
-
Major
-
None
The checkout step currently causes the bitbucket-branch-source plugin to notify Bitbucket of the build result whether that being SUCCESS, FAILED or INPROGRESS (result == null). If you have some build step which sets currentBuild.result = "SUCCESS" before a checkout step this causes a commit to be indicated as good while in fact the build might not be done yet.
The issue can be reproduced with the following pipeline:
stage('stage 1') { node { currentBuild.result = "SUCCESS" } } stage('stage 2') { node { checkout scm // This will cause the plugin to notify status = "SUCCESSFUL", even though the build is still in-progress sleep 20 currentBuild.result = "FAILURE" } } // when onCompleted() gets called the plugin will notify status = "FAILED"
To fix this onCheckout() mustn't be allowed to notify status="SUCCESSFUL", only onCompleted() should do that. You could argue that onCheckout() shouldn't be able to notify other than "INPROGRESS", but allowing it to also notify "FAILED" will give you an early indication that the build failed (if you have a checkout step after the result gets set to !=SUCCESS).