SCM的jenkins管道脚本->错误:获取远程回购源代码时出错

时间:2018-09-25 13:26:15

标签: git jenkins jenkins-pipeline

我正在使用jenkins作为dockerimage 我用下面的git详细信息创建了一个简单的工作: 我确实从jenkins ui添加凭据:-

url: https://myTeam:appPassword@bitbucket.org/MinoxTeam/bizcuit.git
credentials : myTeam /appPassword

这适用于简单的工作

我想为jenkins创建管道并使用jenkinsfile 我对管道使用相同的git凭据 但是错误:无法获取原始主机。 错误是:

stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://team:appPassword.git/'
hudson.plugins.git.GitException: Failed to fetch from https://myTeam.myRepository.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)

我的jenkinsfile

pipeline {
    agent any
    options {
      skipDefaultCheckout()
      }
        stages {
            stage(checkout) {
                steps {
                ws('/var/jenkins_home/workspace/pipelineDemo@script') {
                  git branch: 'feature/jenkinsTest',
                  credentialsId: 'appPassword',
                  url: 'https://myTeam:appPassword@bitbucket.org/myTeam/myRepository.git'

                sh "ls -lat"
                }
              }
            }

1 个答案:

答案 0 :(得分:1)

credentialsId: 'appPassword'必须是凭据的ID,而不是密码本身。