Reputation: 35
I want to fill out a Dynamic Parameter box in Jenkins.
My Groovy script should do the following:
Can you help me with the Groovy script? No idea about Groovy :-(.
Thanks!
Upvotes: 0
Views: 9115
Reputation: 14762
You don't have to write the JSON data to a file to achieve this.
Taking Perfectly working curl command fails when executed in a groovy script and Parsing and producing JSON, 1. JsonSlurper as foundation do the following in a Dynamic Parameter's script:
import groovy.json.JsonSlurper
url= "http://user:pwd@jenkins/api/json"
process = [ 'bash', '-c', "curl ${url}" ].execute()
process.waitFor()
//println process.err.text // for debugging in Jenkins' Script Console
//println process.text
info = new JsonSlurper().parseText(process.text)
return info._class
Output at Build with Parameters:
This build requires parameters:
Dynamic Parameter
hudson.model.Hudson
Upvotes: 2