我的github存储库中的Jenkins文件用于Jenkins Master/Slave环境。我需要在远程Jenkins Slave Server上执行测试命令。在我的声明式管道中,代理的调用方式如下:
stage("Testautomation") {
agent { label 'test-device' }
steps {
bat '''
@ECHO ON
ECHO %WORKSPACE%
... '''
}
}在Jenkins甚至可以执行远程命令之前,它就开始从版本控制中签出。在Jenkins Master上结账没有问题,工作正常。但是在这个Jenkins Slave上,我总是收到这个错误消息。
using credential github-enterprise:...
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://...git # timeout=10
Fetching upstream changes from https://...git
> git --version # timeout=10
using GIT_ASKPASS to set credentials GitHub Enterprise Access Token
> git fetch --tags --force --progress --depth=1 -- https://...git +refs/heads/development:refs/remotes/origin/development # timeout=120
Checking out Revision ... (development)
> git config core.sparsecheckout # timeout=10
> git checkout -f ...
Could not checkout ...发布于 2020-02-06 20:22:36
默认情况下,声明性管道在每个代理上执行SCM签出。检查Jenkins从服务器上是否安装了Git。
相反,如果您希望代码在主服务器上签出,而不是在代理上签出,请禁用options指令中的默认签出,并在阶段中使用scm checkout步骤。
pipeline {
agent { label 'master' }
options {
skipDefaultCheckout(true)
}
stages {
stage('Build') {
steps {
checkout scm
// do other stuff on master
}
}
stage("Testautomation") {
agent { label 'test-device' }
steps {
bat '''
@ECHO ON
ECHO %WORKSPACE%
'''
}
}
}
}您可以进一步自定义检出行为,如本答案https://stackoverflow.com/a/42293620/8895640中所述。
https://stackoverflow.com/questions/60093992
复制相似问题