workflow-cps-global-lib-plugin
workflow-cps-global-lib-plugin copied to clipboard
Fix retry problem on library step
I have observed an intermittent failure fetching library from SCM in a random job about once a day. So i tried to do a retry like this:
retry(3){
library identifier: "my-library@master"
}
But when i do this, i have this error:
[Pipeline] retry
[Pipeline] {
[Pipeline] library
Loading library my-library@master
...
[Pipeline] }
ERROR: Execution failed
hudson.plugins.git.GitException: Command "git.exe ls-remote ... returned status code 128:
...
Retrying
[Pipeline] {
[Pipeline] library
Only using first definition of library my-library
[Pipeline] }
[Pipeline] // retry
[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'methodInMyLibrary' found among steps
If there is an error on first attempt, second retry don't reload the library (Only using first definition of library my-library
).
This pull request fixes this problem.
@philippe-granet Thanks for the PR! I think #47 should fix your problem by using the global "SCM checkout retry count" setting in Jenkins to retry failed library checkouts automatically, which is more consistent with how other Jenkins plugins retry failed SCM checkouts. It would be great if you could take a look and confirm whether that PR addresses your needs.
@dwnusbaum yes, that PR #47 addresses my needs 👍 But if I want to do this, it doesn't work without my PR:
def branchToCheckout=myFunctionReturningBranchToCheckout()
try{
library 'stuff@'+branchToCheckout
}catch(err){
// fallback to master branch if branch does not exits
library 'stuff@master'
}
As of #172 most of the code in this plugin has been moved to another plugin repository so this PR must be closed. If this change is still needed, please
git clone https://github.com/jenkinsci/pipeline-groovy-lib-plugin
cd pipeline-groovy-lib-plugin
git checkout -b PICK-BRANCH-NAME
git pull https://github.com/philippe-granet/workflow-cps-global-lib-plugin master
resolve any merge conflicts, and file a fresh PR on the new repository. Be sure to paste a link to this old PR to enable bidirectional navigation.