首页 > 解决方案 > 来自 SCM 的 jenkins 管道脚本 - > 错误:获取远程 repo 'origin' 时出错

问题描述

我正在使用 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)

我的詹金斯档案

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"
                }
              }
            }

标签: gitjenkinsjenkins-pipeline

解决方案


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


推荐阅读