有人知道为什么吗。
…
steps
{
script
{
sshagent(credentials: ['jenk'])
{
sh "git remote show …" //This does not work !
bat "git remote show …" //This works ??
}
}
}
...
jenk的凭证是通过Jenkins->凭证->系统->全局凭证来管理的。
EDIT:对不起,忘了错误的msg。
Host key verification failed
fatal: Could not read from remote repository
Jenkins使用CYGWIN_NT-6.3-WOW(i686 Cygwin)配置sh命令。
经过这一切命令清除了一切。
if (isUnix())
{
echo "Jenkins runs on Linux"
}
else
{
echo "Jenkins runs on Windows"
}
echo "show shell kernel version (uname -a) : "
def res = sh (script: "uname -a", returnStdout: true)
echo "${res}" //=>CYGWIN_NT-6.3-WOW...
res2 = sh (script: "ls -al ~/.ssh", returnStdout: true)
echo "${res2}"
所以解决上述问题的方法就是在cygwin中添加ssh-keys的功能。
如果你需要你的证书,你可以这样做。https:/codurance.com20190530accessing-and-dumping-jenkins-credentials。