我正在使用DIR()
为多回购我结账创建一个目录。显然它出错而没有任何有意义的错误。
这是我的JenkinsFile片段
try {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: "$GIT_CRED"]
]) {
stage ('Checkout LLM') {
try {
dir('LLMC')
git poll: true , branch: "${GIT_BRANCH}", credentialsId: "${GIT_CRED}", url: "${GIT_REPO}"
echo "checking out"
sh "ls -l"
sh "pwd"
}catch(error) {
echo "## ERROR- 'Git checkout failed'.exiting"
sh "exit 1"
throw error
}
}
错误:
Running in /home/jenkins/workspace/Dev-Pipelines/LLM-engine/LLMC
[Pipeline] dir
[Pipeline] echo
## ERROR- 'Git checkout failed'.exiting
[Pipeline] sh
[LLM-engine] Running shell script
+ exit 1
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] echo
## Outer catch caught error. Exiting...
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
它创建了一个新的目录,但在结账时失败了。它可以在dir()
块之外正常工作。如何启用调试?
答案 0 :(得分:0)
我通过在dir语句中使用花括号来修复它。
try {
dir('LLMC')
{
git poll: true , branch: "${GIT_BRANCH}", credentialsId: "${GIT_CRED}", url: "${GIT_REPO}"
echo "checking out"
sh "ls -l"
sh "pwd"
}
}catch(error) {