简体   繁体   English

Jenkins文件-一条管道中的多仓库

[英]Jenkins File - Multi repo in one pipeline

I am using DIR() to create a directory for multi-repo I checkout. 我正在使用DIR()为我签出的多仓库创建目录。 apparently it error out with no meaningful error. 显然,它没有任何有意义的错误。

Here is my JenkinsFile snippet 这是我的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
        }
                        }

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

It created a new dir and failed while checking out. 它创建了一个新目录,但在签出时失败。 It works fine with out dir() block. 使用out dir()块可以正常工作。 How do I enable debug? 如何启用调试?

I fixed it by having curly braces with in the dir statement. 我通过在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) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM