Open vorburger opened 6 years ago
So maybe we can use the Jenkins REST API for that?
We may use the jenkins-rest
for that which is a java-based client to interact with Jenkins REST API.
@prateekiiest yes, definitely using Jenkins' REST API. It seems there are at least 2 Java client libs:
we need a POC to see which one is easier to use to do the above.
After going through the two libraries, I present here a comparative study of the two.
jenkins-rest
and java-client-api
has provision for adding their corresponding dependency in the maven file. So its quite easy to add the corresponding dependency for the project if we use any of the two.For jenkins-rest
<dependency>
<groupId>com.cdancy</groupId>
<artifactId>jenkins-rest</artifactId>
<version>0.0.10</version>
</dependency>
For java-client-api
<dependency>
<groupId>com.offbytwo.jenkins</groupId>
<artifactId>jenkins-client</artifactId>
<version>0.3.7</version>
</dependency>
Accessing the jenkins URL, through the API
For jenkins-rest
JenkinsClient client = JenkinsClient.builder()
.endPoint("http://127.0.0.1:8080") // end point URL
.credentials("admin:password") //
.build();
For java-client-api
import com.offbytwo.jenkins.JenkinsServer
JenkinsServer jenkins = new JenkinsServer(new URI("http://localhost:8080/jenkins"), "admin", "password")
jenkins-rest
supports many other credentials for login while java-client
follows only the above standard. jenkins-rest
supports Base64 encoded username and password which is not supported by the other one.
Jenkins-rest
is supposed to be built upon a much more modular fashion as opposed to the java-client
. It supports several methods like BuildInfo, endpoints and Build providing more modularity.
jenkins-rest
also supports authentication token
which is not supported in case of java-client
@vorburger your thoughts on this?
FTR: In #20 we found out that cdancy/jenkins-rest is not available on Maven central (only JFrog Bintray's JCenter), whereas jenkinsci/java-client-api is (easily available on Maven central), therefore I now think it would ease future pains if we just went for jenkinsci/java-client-api instead of cdancy/jenkins-rest after all.
will make a PR for that soon :+1:
BTW , I have found another library to use jersey-client
and following the API structure I feel its more easier
The goal of this issue is to raise a PR with a POC that introduces code which:
https://jenkins.opendaylight.org
and the (2) name/path (?) of a job such asreleng/job/integration-multipatch-test-fluorine
and aMap<String, String>
which are used as the build parameters on jobs such as https://jenkins.opendaylight.org/releng/job/integration-multipatch-test-fluorine/build - that URL may not be accessible to you, so here is a screenshot:It may be easiest to explore this locally by downloading Jenkins and setting up a test job with parameters instead of using jenkins.opendaylight.org, because accessing https://jenkins.opendaylight.org/releng/job/integration-multipatch-test-fluorine/build needs special permissions. The eventual goal would be to drive that job by this bot though.
Perhaps someone even already wrote a Java Jenkins client which can do exactly that?