这是我创建的用于处理来自 API 的 json 的管道。但是,当我运行它时,它在第一个循环后失败。
import groovy.json.JsonSlurper
pipeline {
agent none
stages {
stage('Query Pull Requests'){
steps{
script {
def response = httpRequest authentication: 'BitbucketAuth', url: "https://api.bitbucket.org/2.0/repositories/repo-name/pullrequests"
echo "Status: ${response.status}"
def json = new JsonSlurper().parseText(content)
def pullrequests = json.values;
for (int i = 0; i < pullrequests.size(); i++) {
stage("Processing Pull Request ID : ${pullrequests[i].id}"){
echo "${pullrequests[i].source.branch.name}"
echo "${pullrequests[i].destination.branch.name}"
echo "${pullrequests[i].destination.repository.full_name}"
}
}
}
}
}
}
}
詹金斯版 2.107