在管道中使用Jenkins全局凭据(Jenkins文件)
我目前正在詹金斯自动化一个项目。我使用的管道从源代码管理工具(在我的例子中是GIT)读取并执行Jenkins文件。为了实现这一点,我提供GitURL,并使用“Jenkins credentials Provider”提供凭据,然后执行构建。它读取Jenkins文件并签出代码,但在下一阶段失败:在管道中使用Jenkins全局凭据(Jenkins文件),jenkins,automation,jenkins-pipeline,Jenkins,Automation,Jenkins Pipeline,我目前正在詹金斯自动化一个项目。我使用的管道从源代码管理工具(在我的例子中是GIT)读取并执行Jenkins文件。为了实现这一点,我提供GitURL,并使用“Jenkins credentials Provider”提供凭据,然后执行构建。它读取Jenkins文件并签出代码,但在下一阶段失败: pipeline{ agent any stages{ ... stage('Cloning GIT Repo'){ steps{
pipeline{
agent any
stages{
...
stage('Cloning GIT Repo'){
steps{
echo 'Cloning the repository'
git url: 'http://test.git'
}
}
...
它给出了错误:
No credentials specified
有没有一种方法可以让我使用我之前在Jenkins UI中指定的全局凭据?您可以使用
credentialsId
param
git(
url: 'http://test.git',
credentialsId: 'jenkins-credentials',
branch: "${branch}"
)