Jenkins multibranch pipeline failing on bitbucket pull requests with concurrent builds

32 Views Asked by At

edit: this is using atlassian bitbucket

I have a multibranch pipeline that discovers and builds pull requests from bitbucket. This is generally working fine, but I am seeing frequent failures on PR builds where it appears that the git actions are attempting to access files that either don't exist or can't be found on the subsequent build.

I've attached the errors and relevant job config. Not doing anything crazy in the declarative pipeline. I do a cleanWS() at the end of every build as well.

I'm at a loss on what's going on and could use any suggestions.

 post {
        always {
            step([$class: 'Mailer',
                notifyEveryUnstableBuild: true,
                recipients: "[email protected]",
                sendToIndividuals: true])
                
            archiveArtifacts artifacts: 'RPMS/**', fingerprint: true, onlyIfSuccessful: true
            cleanWs (cleanWhenSuccess: false, notFailBuild: true)

        }

I missed it in the job configuration image, but I also have: "Check out to matching local branch" set.

I'm assuming this is a concurrent build issue.

Example workspace info: "Good" build

Workspaces for myproj » PR-255 #5
/var/jenkins_home/workspace/MYPROJ_PR-255@script/a28ec253e3e8f4ca5b7054b74766017f7af6c84894c2087966349f72d6e27eba on built-in
/data0/myproj/workspace/MYPROJ_PR-255 on MYAGENT-agent1

Subsequent failed build:

Workspaces for myproj » PR-255 #6
/var/jenkins_home/workspace/MYPROJ_PR-255@script/a28ec253e3e8f4ca5b7054b74766017f7af6c84894c2087966349f72d6e27eba on built-in
/data0/myproj/workspace/MYPROJ_PR-255@2 on MYAGENT-agent1

Errors:

    Error when executing always post condition:
    Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: bcfd72d0-fd9e-4926-9d04-8c3f810e6c7c
    org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing
    Perhaps you forgot to surround the step with a step that provides this, such as: node, dockerNode
        at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:90)
        at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:71)
        at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worke



Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to MYAGENT-agent1
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
        at hudson.remoting.Channel.call(Channel.java:1003)
        at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:153)
        at jdk.internal.reflect.GeneratedMethodAccessor2916.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:138)
        at com.sun.proxy.$Proxy145.execute(Unknown Source)
        at jenkins.plugins.git.MergeWithGitSCMExtension.decorateRevisionToBuild(MergeWithGitSCMExtension.java:120)
        at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1162)
        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1306)
        at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
        at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
        at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
        at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 0e5359a8-378f-46f4-a04b-6a38dc1f0e22
hudson.plugins.git.GitException: Command "git merge b093ec6b2a7e28073c0854fd01433212b73497f0" returned status code 128:
stdout: 
stderr: error: open("some/code.py"): Operation not permitted
fatal: Unable to process path some/code.py
Cannot save the current worktree state
fatal: stash failed

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2842)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2079)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2070)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$3.execute(CliGitAPIImpl.java:984)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:377)
    at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

Job Configuration:

0

There are 0 best solutions below