我的系统设置为 Docker Linux PC Master/BeagleBone Linux Slave,通过 USB SSH 连接。
本质上,我正在尝试执行以下操作:
当我从 Jenkins 构建时,我的主人克隆存储库,构建代码并存储二进制文件。但是,当我转移到从属设备上的“闪存”阶段时,它也尝试克隆存储库(由于凭据问题而失败 - 这是一个单独的问题)。我不希望它这样做 - 相反,我希望它只获取新存储的文件并使用它来刷新附加的硬件,而不是在存储库中查找它。
我似乎找不到阻止这种情况发生的选项。我可以做什么来只使用隐藏的文件?如果无法通过存储来实现,是否可以通过其他方式完成而不需要从站尝试克隆存储库?
这是我的 Jenkinsfile:
pipeline {
agent none
stages {
stage('Build') {
agent {
label 'master'
}
steps {
sh 'cd application/.../example && make'
stash includes: 'application/.../example/example.bin', name: 'Flash'
}
}
stage('Test of Flash') {
agent {
label 'test_slave'
}
steps {
unstash 'Flash'
//Flashing step here
sh 'make check || true'
}
}
}
}
这是控制台日志,从主编译开始:
obtained Jenkinsfile from 913...
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] node
Running on Jenkins in /var/jenkins_home/...
[Pipeline] {
[Pipeline] checkout
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository [email protected]:...
//Later, the file compiles:
Generating binary and Printing size information:...
//Compiles, then:
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test of Flash)
[Pipeline] node
Running on test_slave in /home/debian/...
[Pipeline] {
[Pipeline] checkout //And it starts to clone the repo here!
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository [email protected]:...
我不希望它执行上述操作。
显然,同样的问题以不同的形式发布在这里:https://devops.stackexchange.com/questions/650/set-a-jenkins-job-to-not-to-clone-the-repo-in -scm/1074
无论如何,具体做法如下:您需要在第一个代理之后添加一个名为
options { skipDefaultCheckout() }
的选项,这样一般情况下,它就不会轮询 scm(因为检查 git 的命令是 checkout scm. )
然后,在您确实想要检查 git 的阶段,输入
checkout scm
作为步骤。
这是新的 Jenkinsfile:
pipeline {
agent none
options { skipDefaultCheckout() } //THIS ONE
stages {
stage('Build') {
agent {
label 'master'
}
steps {
checkout scm //AND THIS ONE
sh 'cd application/...
}
}
stage('Test of Flash') {
agent {
label 'test_slave'
}
steps {
sh 'cd application/...
sh 'make check || true'
}
}
}
}
(事实上,存储是不必要的。)