Git 将Credentail传递给Jenkins文件
我已经为我的项目编写了Jenkinsfile,它有很多阶段,在其中的一个阶段中,我需要克隆我的私有git repo,它需要通过creds才能下载代码。我不知道如何将这些信誉传递给克隆回购。我的詹金斯档案是这样的-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://
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'
}
}
}
}