Jenkins - 为什么在sshagent插件中,bat控制台可以工作,而sh控制台却不行?

问题描述 投票:0回答:1

有人知道为什么吗。

…
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 ssh
1个回答
0
投票

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。

© www.soinside.com 2019 - 2024. All rights reserved.