This is the pipeline I have created for processing a json from an API. However when I run this it fails after the first loop.
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}"
}
}
}
}
}
}
}
This is the error I am getting
Jenkins ver. 2.107