Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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
Git 将Credentail传递给Jenkins文件_Git_Jenkins_Jenkins Pipeline - Fatal编程技术网

Git 将Credentail传递给Jenkins文件

Git 将Credentail传递给Jenkins文件,git,jenkins,jenkins-pipeline,Git,Jenkins,Jenkins Pipeline,我已经为我的项目编写了Jenkinsfile,它有很多阶段,在其中的一个阶段中,我需要克隆我的私有git repo,它需要通过creds才能下载代码。我不知道如何将这些信誉传递给克隆回购。我的詹金斯档案是这样的- pipeline { agent any environment { HOME_DIR = "$WORKSPACE/" } stages { stage('clone repos') { steps { **sh 'git clone http://

我已经为我的项目编写了Jenkinsfile,它有很多阶段,在其中的一个阶段中,我需要克隆我的私有git repo,它需要通过creds才能下载代码。我不知道如何将这些信誉传递给克隆回购。我的詹金斯档案是这样的-

pipeline {
agent any
environment {
      HOME_DIR = "$WORKSPACE/"
      }
stages {
stage('clone repos') {
  steps {
    **sh 'git clone http://<repo_url> '**
  }
}
}

我需要通过我的信用来克隆回购协议。有人知道如何通过信用吗??非常感谢您的帮助。

首先用您的git用户名和密码创建一个凭证。然后使用Jenkins文件中的凭证id

台阶

单击侧栏中的凭据链接

单击全局凭据域

单击[添加凭证]

选择可从生成作业中使用的凭据类型

用户名和密码-用户名/密码对

pipeline {
agent any
stages {
stage('clone repos') {
  steps {

   dir ("example"){                 
        git branch: 'master', credentialsId: 'your_credential_id', url: 'https://github.com/jenkinsci/examples.git'

    }
  }
}
}