Open derhecht opened 3 years ago
btw Jenkins 2.289.1 & Plugin 2.7.2
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Still facing this (or at least very closely related) issue in Jenkins 2.478 with plugin version 3.1.2.
The trigger is hooking into the checkout of the SharedLibrary and is overriding the branch being checked out, causing the whole pipeline to fail.
Having a repo filter, recommended by the OP, would solve this issue, just like it does for git branch parameters. Alternatively the trigger should probably check that it is affecting only SCM operations related repository in the trigger.
TLDR; Pipeline script starts as follows:
@Library('my-shared-lib@develop') _
pipeline {
As the first step the job attempts to checkout the library from git, but instead of checking out develop
branch (specified by @develop
) the trigger seems to override it and attempts to checkout the commit hash of the PR branch resulting in failure:
Started by user my-name: Bitbucket PPR: comment created for pull request Loading library my-shared-lib@develop Attempting to resolve develop from remote references... > git --version # timeout=10 > git --version # 'git version 2.43.5' using GIT_SSH to set credentials GIT SSH Key of jenkins user Verifying host key using known hosts file, will automatically accept unseen keys > git ls-remote -h -- ssh://git@git.org-server.com/~my-name/jenkins-shared-library.git # timeout=10 Found match: refs/heads/develop revision 80c00f3eb6c3b3e7466c288c438ee0877686cc5c The recommended git tool is: NONE using credential 914a90b9-4715-487a-a44c-f70bc667c5ff > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/vj-criseamix-pr-builder@libs/e08b451f8de72288c88a62da39bf4d03794e1961a9d50c24221659ff212f719c/.git # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url ssh://git@git.org-server.com/~my-name/jenkins-shared-library.git # timeout=10 Fetching without tags Fetching upstream changes from ssh://git@git.org-server.com/~my-name/jenkins-shared-library.git > git --version # timeout=10 > git --version # 'git version 2.43.5' using GIT_SSH to set credentials GIT SSH Key of jenkins user Verifying host key using known hosts file, will automatically accept unseen keys > git fetch --no-tags --force --progress -- ssh://git@git.org-server.com/~my-name/jenkins-shared-library.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse b1e487954a69d10c0a6400c7d9390d2a7c81cf86^{commit} # timeout=10 ERROR: Checkout failed hudson.plugins.git.GitException: Command "git rev-parse b1e487954a69d10c0a6400c7d9390d2a7c81cf86^{commit}" returned status code 128: stdout: b1e487954a69d10c0a6400c7d9390d2a7c81cf86^{commit} stderr: fatal: ambiguous argument 'b1e487954a69d10c0a6400c7d9390d2a7c81cf86^{commit}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git[ ...] -- [ ...]' at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2846) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2766) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2761) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2051) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2063) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:1115) at PluginClassLoader for git-client//hudson.plugins.git.GitAPI.revParse(GitAPI.java:419) at PluginClassLoader for git//hudson.plugins.git.RevisionParameterAction.toRevision(RevisionParameterAction.java:98) at PluginClassLoader for git//hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1138) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1306) at PluginClassLoader for workflow-scm-step//org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.lambda$doRetrieve$4(SCMBasedRetriever.java:200) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.retrySCMOperation(SCMBasedRetriever.java:222) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.doRetrieve(SCMBasedRetriever.java:199) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:79) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:264) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.LibraryAdder.add(LibraryAdder.java:151) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.LibraryDecorator$1.call(LibraryDecorator.java:125) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1087) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293) at PluginClassLoader for script-security//org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox$Scope.parse(GroovySandbox.java:163) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:190) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:175) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:635) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:581) at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:335) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:445) ERROR: Maximum checkout retry attempts reached, aborting
In the example above the b1e487954a69d10c0a6400c7d9390d2a7c81cf86 hash it attempted to apply to library checkout was the cash of the branch from the PR, which should have only applied to main git checkout, and not the library.
I attempted to disable branch overrides for the library in system configs.
And also tried to load library after the main git checkout:
steps {
git branch: params.branch, url: 'ssh://git@git.org-server.com/my-repo.git'
library('my-shared-lib@develop')
No success, during library checkout bitbucket trigger still overrides the commit hash and fails.
Have a multibranch pipeline project which make use of a shared pipeline library. Build trigger failed as
// TODO: is it needed? There is only a remote, the HTML one, that is used the do // the // match boolean isRemoteSet = false; for (URIish remote : remotes) { if (match(scmTrigger, remote)) { isRemoteSet = true; break; } }
(BitBucketPPRJobProbe.java) does not match. It compares "Trying to match ssh://jenkins-pipeline.git<-->ssh://my-code-repo.git" and so stays false. Had a similar problem in gitParameter plugin where I have to set a "useRepository" filter to ensure proper selection from my-code-repo.git instead of jenkins-pipeline.git. We also have two "Git Build Data" icons in our job sidebar - one for my-code-repo and one for jenkins-pipeline.So may we need a filter here too? It just logs "Considering to use trigger hudson.plugins.git.GitSCM" once when
item.ifPresent(i -> i.getSCMs().stream().forEach(scmTrigger -> { logger.log(Level.FINE, "Considering to use trigger {0}", scmTrigger.toString());
May another scm source has to be added orOptional<SCMTriggerItem> item = Optional.ofNullable(SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job));
already filters out the needed one?