如何解决多分支管道共享库权限错误
我在Docker容器中运行Jenkins,作业在单独的容器中运行。我目前在使用共享库的多分支管道上遇到错误。作业第一次克隆共享库,但是从那里开始会出现权限错误。我似乎在网上找不到类似的问题或解决方案。
Loading library <SHARED_LIBRARY>@develop
Attempting to resolve master from remote references...
> git --version # timeout=10
using GIT_SSH to set credentials <CREDENTIAL_NAME>
> git ls-remote -h -- <GIT_LINK> # timeout=10
Found match: refs/heads/develop revision <COMMIT_HASH>
ERROR: Checkout failed
java.nio.file.AccessDeniedException: /${ITEM_ROOTDIR}
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
at java.nio.file.Files.createDirectories(Files.java:767)
at hudson.FilePath.mkdirs(FilePath.java:3260)
at hudson.FilePath.access$1300(FilePath.java:211)
at hudson.FilePath$Mkdirs.invoke(FilePath.java:1251)
at hudson.FilePath$Mkdirs.invoke(FilePath.java:1247)
at hudson.FilePath.act(FilePath.java:1075)
at hudson.FilePath.act(FilePath.java:1058)
at hudson.FilePath.mkdirs(FilePath.java:1243)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:828)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1166)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.lambda$doRetrieve$1(SCMSourceRetriever.java:157)
at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrySCMOperation(SCMSourceRetriever.java:107)
at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.doRetrieve(SCMSourceRetriever.java:156)
at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:96)
at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:157)
at org.jenkinsci.plugins.workflow.libs.LibraryAdder.add(LibraryAdder.java:138)
at org.jenkinsci.plugins.workflow.libs.LibraryDecorator$1.call(LibraryDecorator.java:125)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
ERROR: Checkout failed
第一次运行作业时,共享管道将在主服务器上克隆,并在路径上被克隆
<JENKINS_HOME>/jobs/<JOB_NAME>/branches/<BRANCH_NAME>/workspace/<GIT_REPO_NAME>/<SHARED_LIBRARY_BRANCH_NAME@libs/<SHARED_LIBRARY_GIT_REPO_NAME>
我在从属容器上看不到它。我相信Jenkins代理程序具有特权,因为它以admin身份运行,并且docker容器对路径具有权限。 这是第一次运行时的日志,您可以看到它可以克隆共享管道并启动从属容器,但是如果您查看该帖子(同一作业的第二次运行)。无法克隆共享管道。
Branch indexing
Running as admin
> git rev-parse --is-inside-work-tree # timeout=10
Setting origin to git@github.com:<GIT_REPO>.git
> git config remote.origin.url git@github.com:<GIT_REPO>.git # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git --version # timeout=10
> git config --get remote.origin.url # timeout=10
using GIT_SSH to set credentials <GITHUB_SSH_KEY>
> git fetch --tags --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
Seen branch in repository origin/develop
Seen branch in repository origin/master
Seen 2 remote branches
Obtained Jenkinsfile from <GIT_HASH>
Running in Durability level: PERFORMANCE_OPTIMIZED
Loading library <SHARED_LIBRARY>@develop
Attempting to resolve develop from remote references...
> git --version # timeout=10
using GIT_SSH to set credentials <GITHUB_SSH_KEY>
> git ls-remote -h -- git@github.com:<SHARED_LIBRARY>.git # timeout=10
Found match: refs/heads/develop revision <GIT_HASH>
using credential <GITHUB_SSH_KEY>
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository git@github.com:<SHARED_LIBRARY>.git
> git init /var/jenkins_home/jobs/<JOB_NAME/GIT_REPO_NAME>/branches/develop/workspace/<JOB_NAME/GIT_REPO_NAME>/develop@libs/<SHARED_LIBRARY> # timeout=10
Fetching upstream changes from git@github.com:<SHARED_LIBRARY>.git
> git --version # timeout=10
using GIT_SSH to set credentials <GITHUB_SSH_KEY>
> git fetch --no-tags --progress -- git@github.com:<SHARED_LIBRARY>.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url git@github.com:<SHARED_LIBRARY>.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url git@github.com:<SHARED_LIBRARY>.git # timeout=10
Fetching without tags
Fetching upstream changes from git@github.com:<SHARED_LIBRARY>.git
using GIT_SSH to set credentials <GITHUB_SSH_KEY>
> git fetch --no-tags --progress -- git@github.com:<SHARED_LIBRARY>.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Checking out Revision <GIT_HASH> (develop)
> git config core.sparsecheckout # timeout=10
> git checkout -f <GIT_HASH> # timeout=10
Commit message: "<SHARED_LIBRARY_COMMIT_MESSAGE>"
First time build. Skipping changelog.
[Pipeline] Start of Pipeline
[Pipeline] node
Running on android-slave on docker in /home/jenkins/workspace/<JOB_NAME>
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Jenkinsfile
#!groovy
@Library("<SHARED_LIBRARY>")
pipeline {
agent {
label 'android-slave'
}
stages {
stage("Stage1") {
steps {
script {
println "Testing multi branch pipeline"
}
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。