我有Jenkins Master并在Windows Slave上运行作业。我正在尝试将提交提交到git repo,但是不能按预期工作
下面是我的管道脚本
{node('win2k12') {
def artifactTagVersion = params.TAG_VERSION
if(artifactTagVersion) { // groovy treats null or empty strings as false
print "Building in Release mode for version: ${artifactTagVersion}"
// create flag to define that release mode is active
isRelease = true
} else {
print "Building in SNAPSHOT mode"
}
stage("Checkout & Use git"){
deleteDir()
checkout scm
if(isRelease){
print "Preparing sources for releasing."
// go into headless mode
bat "git checkout --detach HEAD"
bat "echo v${artifactTagVersion} > versionFile.txt"
def commitMessage = "Release for version ${artifactTagVersion}"
sshagent(['a075b609-adaf-233d7f3be0a0']) {
bat "git add ."
bat "git commit -m \"${commitMessage}\""
bat "git tag -a v${artifactTagVersion} -m \"${commitMessage}\""
bat "git push origin v${artifactTagVersion}"
}
}
}
这是我在构建时遇到的错误
E:\jenkins\slave\workspace\test-job-trainex---dev---ts>git push origin v1
Could not create directory '/home/SYSTEM/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我一无所知,试图对此进行大量搜索,但是没人能回答为什么它在Windows机器和路径看起来像linux的情况下为什么要查找目录和键。
答案 0 :(得分:0)
我理解了这个问题,问题出在Windows Slave。因此,在设置Windows从站时,我们确实将其设置为服务。 虽然我们将Windows服务设置为更好,但始终最好使用凭据对其进行配置。
也可以安装git bash而不是cygwin,它将对sshd服务起作用。就是这样,现在一切正常。