Jenkins git在代理不工作时签出
我的github存储库中的Jenkins文件用于Jenkins主/从环境。 我需要在远程Jenkins从属服务器上执行测试命令。 在我的声明性管道中,代理的调用方式如下:Jenkins git在代理不工作时签出,jenkins,jenkins-pipeline,Jenkins,Jenkins Pipeline,我的github存储库中的Jenkins文件用于Jenkins主/从环境。 我需要在远程Jenkins从属服务器上执行测试命令。 在我的声明性管道中,代理的调用方式如下: stage("Testautomation") { agent { label 'test-device' } steps { bat ''' @ECHO ON ECHO %WORKSPACE% ... ''' } } 在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 相反,如果希望代码在主机上签出而不是在代理上签出,请在
选项
指令中禁用默认签出,并在后台使用scm签出
步骤
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%
'''
}
}
}
}
您可以进一步自定义此答案中所述的签出行为。如果禁用默认的scm签出,则当{expression{return hasChanges('test/')}}仍在工作时,是否在类似于
的阶段进行更改检测?是的,这不会产生影响。