Open dtrunk90 opened 3 years ago
You can get job parameters if your job already executed once
public static Map<String, String> getParameter(String jenkinsUrl, String userName, String passWord, String jobName) {
Map<String, String> hashMap = new HashMap<String, String>();
try {
JenkinsServer jenkinsServer = new JenkinsServer(new URI(jenkinsUrl),userName,passWord);
JobWithDetails jobWithDetails = jenkinsServer.getJob(jobName);
if (jobWithDetails.details().hasFirstBuildRun() && !jobWithDetails.getLastBuild().details().getParameters().isEmpty()) {
hashMap.putAll(jobWithDetails.getLastSuccessfulBuild().details().getParameters());
} else {
// your logic
}
} catch (URISyntaxException | IOException e) {
e.printStackTrace();
}
return hashMap;
}
That's how to get parameters from a build. I would like to get them from the Job itself.
@dtrunk90 if desperate, you could fetch the job XML and parse it:
String xml = jenkinsServer.getJobXml(jobName)
Shouldn't the parameters be part of the
JobWithDetails
object?