2017-01-04 8 views
1

としてプライベートbitbucketリポジトリ(stashリポジトリ)にあるgitプロジェクトを複製するコードとしてjenikinsパイプラインを使用してください。私はこのコードブロックを使って私のパイプラインスクリプトでプロジェクトをクローンしました。jenkinsを使用してbitbucketプライベートリポジトリからクローンコード

node { 
//checkout from master 
stage 'checkout' 
    withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) { 

     git url: 'https://[email protected]/stash/scm/test_automation.git' , branch: 'development' 
    } 
} 

「MyID」は認証情報IDで、私のユーザー名とパスワードは正しいです。j認証情報をjenkinsのグローバル認証情報に保存します。しかし、私はジェンキンスタスクを構築するときにこのエラーが発生します。私paulrdaアカウントでどこでもMy Macマシンで

 
ERROR: Error fetching remote repo 'origin' 
hudson.plugins.git.GitException: Failed to fetch from https://[email protected]/stash/scm/test_automation.git 
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803) 
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063) 
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73) 
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) 
    at hudson.security.ACL.impersonate(ACL.java:221) 
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://[email protected]/stash/scm/test_automation.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: 
stdout: 
stderr: fatal: Authentication failed for 'https://[email protected]/stash/scm/test_automation.git/' 

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315) 
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:801) 

私は正常ジェンキンスパイプラインスクリプトを使用して、私のプロジェクトのクローンを作成することができますが、私は別のアカウントに変更し、ジェンキンスを実行したときに私はこのエラーを取得します。まだ私はこのエラーを得る理由を理解できません。この問題の解決策を提示してください。

私の設定。
ジェンキンスバージョン:2.19.2
資格のプラグイン:2.1.8
のGitプラグイン:3.0.0
のGitクライアントプラグイン:2.1.0

+0

は、認証が」httpsのために失敗した 'と言います上記(意図によって?)。しかし、ユーザー名とパスワードを確認してください。 'withCredentials'ステップの中で' sh "echo $ GIT_PASSWORD" 'を使って検証することもできます。 – StephenKing

+0

エラーメッセージ全体を読むと、おそらく問題を解決するだけでなく、匿名化を適用するのに役立ちます。 – StephenKing

答えて

4

それあなたが資格情報を渡していないため、認証に失敗しますgitが正しく呼び出されます。

シェルコマンドではなくGitプラグインを使用しているので、実際にはwithCredentialsを使用する必要はありません。あなたはそのように、credentialsId直接gitへの呼び出しを渡すことができます:// ralles @あなたのコードとは異なるユーザー名である、dev.zaizi.org`:エラーメッセージの下に

stage('checkout') { 
    git credentialsId: 'MyID', url: 'https://devMyCompany.org/stash/scm/test_automation.git', branch: 'development' 
} 
関連する問題