在SCM结账后遍历回购时,Jenkins不提供任何文件或目录

时间:2018-04-30 10:23:50

标签: jenkins jenkins-pipeline

詹金斯版本:2.107.1 问题:虽然文件存在,但Jenkins无法访问它或cd进入仓库。

注意:在实际代码中用实际的github repo替换 管道代码: `

node {
   stage('Checkout SCM') {
       checkout([$class: 'GitSCM', branches: [[name: '*/*********']],    doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '******', url: 'https://github.com/******']]])
   }
   stage('Copy the file from the Jenkins-script in the workspace and run it') {
       sh 'pwd'
       sh 'ls -lrt $WORKSPACE'
       sh 'ls -lrt $WORKSPACE/<repo>/jenkins_scripts/'
       sh 'bash $WORKSPACE/<repo>/jenkins_scripts/test-snapshot.sh'
   }
}

` 控制台输出:

`
[Pipeline] sh
[snap] Running shell script
+ ls -lrt /root/workspace/snap/<repo>/jenkins_scripts/
ls: cannot access '/root/workspace/snap/<repo>/jenkins_scripts/': No such file or directory
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 2
Finished: FAILURE
`

0 个答案:

没有答案