在声明性 Jenkins 管道中引用 Folder-level 范围凭证
Referencing Folder-level scope credentials in declarative Jenkins pipeline
问题
我有以下脚本作为 Jenkins 中声明性管道的一部分
stages {
stage('sql') {
steps {
step([
$class: 'SQLPlusRunnerBuilder',
credentialsId:"sis-database-prod-schema-test",
instance:"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db_${ENVIRONMENT}.int.excelsior.edu)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=${ENVIRONMENT})))",
scriptType:'userDefined',
script: '',
scriptContent:"select*from dual",
customOracleHome: '/usr/lib/oracle/12.2/client64'
])
}
}
}
您会注意到我引用的是凭证 ID sis-database-prod-schema-test
。当我在全球范围内确定此凭据的范围时,此脚本有效。但是,当我将凭证范围限定在文件夹级别时,会出现以下错误
ERROR: Invalid credentials [sis-database-prod-schema-test]. Failed to initialize credentials or load user and password
这是我的 folder-level 范围配置的屏幕截图
附加信息
当我将凭据限定在文件夹级别时,我可以在配置下拉元素中看到它 ONLY 当我在适当的文件夹中时。所以,在我看来,作用域配置是正确的,但引用(在代码中)是错误的。
The entry I have highlighted is the sis-database-prod-schema-test credential ID. The one below it ( sis-test-database-prod-schema ) is a global credential unrelated to this question
编辑:这是一个已知问题
这是一个known bug that the author was unable to fix. The relevant code is here。您可以发出拉取请求来修复错误。
已知问题
这是一个known bug that the author was unable to fix. The relevant code is here。您可以发出拉取请求来修复错误。
我不知道您是否仍然关心,但我刚刚为此提交了一个 pull request,它被接受了。现在这个问题应该已经解决了。
问题
我有以下脚本作为 Jenkins 中声明性管道的一部分
stages {
stage('sql') {
steps {
step([
$class: 'SQLPlusRunnerBuilder',
credentialsId:"sis-database-prod-schema-test",
instance:"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db_${ENVIRONMENT}.int.excelsior.edu)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=${ENVIRONMENT})))",
scriptType:'userDefined',
script: '',
scriptContent:"select*from dual",
customOracleHome: '/usr/lib/oracle/12.2/client64'
])
}
}
}
您会注意到我引用的是凭证 ID sis-database-prod-schema-test
。当我在全球范围内确定此凭据的范围时,此脚本有效。但是,当我将凭证范围限定在文件夹级别时,会出现以下错误
ERROR: Invalid credentials [sis-database-prod-schema-test]. Failed to initialize credentials or load user and password
这是我的 folder-level 范围配置的屏幕截图
附加信息
当我将凭据限定在文件夹级别时,我可以在配置下拉元素中看到它 ONLY 当我在适当的文件夹中时。所以,在我看来,作用域配置是正确的,但引用(在代码中)是错误的。
The entry I have highlighted is the sis-database-prod-schema-test credential ID. The one below it ( sis-test-database-prod-schema ) is a global credential unrelated to this question
编辑:这是一个已知问题
这是一个known bug that the author was unable to fix. The relevant code is here。您可以发出拉取请求来修复错误。
已知问题
这是一个known bug that the author was unable to fix. The relevant code is here。您可以发出拉取请求来修复错误。
我不知道您是否仍然关心,但我刚刚为此提交了一个 pull request,它被接受了。现在这个问题应该已经解决了。