基于groovy的Jenkins Pipeline:无法推送到git:权限被拒绝(公钥)

时间:2018-08-01 09:54:45

标签: jenkins groovy jenkins-pipeline groovyshell jenkins-groovy

我正在尝试使用groovy管道语法将一些更改推送到git存储库。但是我无法推动。谁能在这里帮助我。

管道语法:

        sh '''
        #git checkout pkg_version
        touch README
        git add .
        git status
        git commit -m "Updated Package Version"
        git remote -v
        sshagent(credentialsId) {
            git push origin pkg_version
        }
        #git push origin pkg_version
        '''

詹金斯错误:

origin  ssh://jenkins@gerrit:29418/sfdx_nar (fetch)
origin  ssh://jenkins@gerrit:29418/sfdx_nar (push)
+ git push origin pkg_version
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[Pipeline] }  

1 个答案:

答案 0 :(得分:1)

尝试在管道中像这样使用SSHAgent:

<?xml version="1.0" encoding="utf-8" ?>
<controls:ViewPage xmlns="http://xamarin.com/schemas/2014/forms"
                   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                   x:Class="XXXX.ActOverviewView"
                   xmlns:controls="XXXX"
</controls:ViewPage>