在jenkins管道脚本中使用curl获取json文件,之后如何获取依赖列表的列表值并触发这些作业?
{
"Dependencies": [
"Dep1",
"Dep2",
"Dep3"
]
}
我目前的程序看起来是这样的,这是不工作。并获得值后,我需要形成Jenkins作业和触发器从管道
pipeline {
agent {
label 'Dep-Demo'
}
stages{
stage('Getting Dependecies jason-object'){
steps {
script {
final String url = "https://***************/repository/files/sample.jason/raw?ref=main"
withCredentials([usernamePassword(credentialsId: 'api', passwordVariable: 'PASSWORD', usernameVariable: 'USELESS')]) {
sh ''' echo $PASSWORD '''
def response = sh(script: "curl -s --header \"PRIVATE-TOKEN: $PASSWORD\" $url ", returnStdout:true)
echo "***** $response"
def jsonObj = readJSON text: response.join(" ")
echo jsonObj
1条答案
按热度按时间0lvr5msh1#
检查以下示例。