我的github存储库中的Jenkins文件在Jenkins Master / Slave环境中使用。我需要在远程Jenkins从服务器上执行测试命令。在我的声明性管道中,该代理的调用方式如下:
stage("Testautomation") {
agent { label 'test-device' }
steps {
bat '''
@ECHO ON
ECHO %WORKSPACE%
... '''
}
}
在Jenkins甚至可以执行远程命令之前,它开始从版本控制中检出。 Jenkins Master的结帐没有问题,并且工作正常。但是在此詹金斯奴隶上,我总是收到此错误消息。
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 ...
默认情况下,声明性管道对每个代理执行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中的说明进一步自定义结帐行为。