Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Jenkins多分支管道作业中运行Git命令_Git_Jenkins_Continuous Integration_Jenkins Pipeline - Fatal编程技术网

在Jenkins多分支管道作业中运行Git命令

在Jenkins多分支管道作业中运行Git命令,git,jenkins,continuous-integration,jenkins-pipeline,Git,Jenkins,Continuous Integration,Jenkins Pipeline,我正在尝试运行Git命令,以查找Git repo中是否已经存在分支,但它的对象是它失败并出现错误: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 这是我试图运行的命令: def branch_exists_in_angular = sh(script: 'git ls-remote --heads $ANGULAR_REPO $CHECKOUT_BRANCH | wc -l', returnStdout: true)

我正在尝试运行Git命令,以查找Git repo中是否已经存在分支,但它的对象是它失败并出现错误:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
这是我试图运行的命令:

def branch_exists_in_angular = sh(script: 'git ls-remote --heads $ANGULAR_REPO $CHECKOUT_BRANCH | wc -l', returnStdout: true)
是否有一种方法可以将git ssh密钥传递给上述命令,使其运行良好。 我在某处发现了以下示例:

sshagent(['my-git-ssh']){
def branch_exists_in_angular = sh(script: 'git ls-remote --heads $ANGULAR_REPO $CHECKOUT_BRANCH | wc -l', returnStdout: true)
}
但它没有说sshagent不是有效的DSL

根据评论中的建议,我安装了ssh代理插件并尝试再次运行它。。。但这次它失败了,出现了错误:

/usr/bin/git: /usr/bin/git: cannot execute binary file

您是否安装了sshagent插件?如果安装了该步骤,则该步骤应可用。可以在作业中使用管道语法选项进行检查。我刚刚安装了sshagent插件并尝试重新运行,但这次失败,错误为:/usr/bin/git:/usr/bin/git:无法执行二进制文件任何线索?只是要确认是否安装了git插件?是的,我安装了git插件。我可以在服务器上手动运行此操作。。。但通过詹金斯,它失败了。