gpt4 book ai didi

linux - 不想让 Jenkins Slave 克隆 repo?

转载 作者:太空宇宙 更新时间:2023-11-04 09:15:37 24 4
gpt4 key购买 nike

我的系统设置为 Docker Linux PC Master/BeagleBone Linux Slave,通过 USB SSH 连接。

本质上,我正在尝试执行以下操作:

  • 在从 Bitbucket 存储库中获取的 master 上编译代码。
  • 获取编译后的二进制文件并将其传输到 BeagleBone(我在 Jenkinsfile 中使用“stash”和“unstash”来执行此操作)
  • 使用 BeagleBone 从属设备上的二进制文件来刷写与其连接的另一个设备(从属设备,而不是主设备)

当我从 Jenkins 构建时,我的主人会克隆存储库、构建代码并存储二进制文件。但是,当我转移到从服务器上的“闪存”阶段时,它尝试克隆存储库(由于凭证问题而失败 - 这是一个单独的问题)。我不希望它这样做 - 相反,我希望它只获取新存储的文件并使用它来刷新连接的硬件,而不是在存储库中查找它。

我似乎找不到防止这种情况发生的选项。我该怎么做才能使用隐藏的文件?如果 stash 不可行,是否可以在 slave 不尝试克隆 repo 的情况下以另一种方式完成?

这是我的 Jenkins 文件:

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 git@bitbucket.org:...

//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 git@bitbucket.org:...

我不希望它执行上述操作。

最佳答案

显然,同样的问题以不同的形式发布在这里: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'
}
}
}
}

(碰巧,存储是不必要的。)

关于linux - 不想让 Jenkins Slave 克隆 repo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48217650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com