[英]Jenkins Multibranch Pipeline workspace configuration
I'm bumping up against JENKINS-38706 . 我碰到JENKINS-38706 。 And since its been open for a while, i'm trying to work around it. 由于它已经开放了一段时间,所以我正在尝试解决它。
My problem is that i'm running a multinode pipeline, with one of the nodes being a windows slave, with the 255 character path limitations. 我的问题是我正在运行多节点管道,其中一个节点是Windows从站,具有255个字符的路径限制。
So, i'm trying to change the workspace for my windows slave stages, and instead of using C:\\jenkins\\workspace\\job-branch-randomcharacters that the multibranch pipeline uses, i'm trying to move it to c:\\w\\job\\branch. 因此,我尝试更改Windows从属阶段的工作区,而不是使用多分支管道使用的C:\\ jenkins \\ workspace \\ job-branch-randomcharacters,而是尝试将其移至c:\\ w \\工作\\分支。
It immediately fails with: 它立即失败并显示:
Branch indexing
Obtained Jenkinsfile from 5bc168fcd5b3707048ad4bca4b5ef7478d759531
Running in Durability level: MAX_SURVIVABILITY
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
[Bitbucket] Notifying commit build result
[Bitbucket] Build result notified
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 52: Too many arguments for map key "ws" @ line 52, column 15.
ws('C:\\w\\$JOB_NAME\\$BRANCH_NAME') {
My Jenkinsfile snippet: 我的Jenkinsfile片段:
stage ('Snapshot-WINDOWS') {
agent {
node {
label 'win'
ws('C:\\w\\$JOB_NAME\\$BRANCH_NAME') {
body()
}
}
}
steps {
withMaven(
maven: 'Maven 3.5.3',
mavenSettingsConfig: 'settings'
) {
bat 'mvn clean install'
}
}
}
You forgot to declare the workspace. 您忘记了声明工作空间。 Example: 例:
def wsDir = "/some/path/${env.BRANCH_NAME}"
ws (wsDir) {
// some block
}
To answer my own question, instead of using ws() i needed to use customWorkspace, and the $BRANCH_NAME gets automatically added with multibranch pipelines. 为了回答我自己的问题,我不需要使用ws(),而是需要使用customWorkspace,并且$ BRANCH_NAME会自动添加到多分支管道中。
stage ('Snapshot-WINDOWS') {
agent {
node {
label 'win'
customWorkspace 'C:\\w\\$JOB_NAME'
}
}
steps {
withMaven(
maven: 'Maven 3.5.3',
mavenSettingsConfig: 'settings'
) {
bat 'mvn clean install'
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.