vorburger / opendaylight-bot

Eclipse Public License 1.0
0 stars 2 forks source link

POC to start jobs "Build with Parameters" on a Jenkins #8

Open vorburger opened 6 years ago

vorburger commented 6 years ago

The goal of this issue is to raise a PR with a POC that introduces code which:

jenkins opendaylight org_releng_job_integration-multipatch-test-fluorine_build

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?

prateekiiest commented 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.

vorburger commented 6 years ago

@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.

prateekiiest commented 6 years ago

After going through the two libraries, I present here a comparative study 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>
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.

prateekiiest commented 6 years ago

@vorburger your thoughts on this?

vorburger commented 6 years ago

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.

prateekiiest commented 6 years ago

will make a PR for that soon :+1:

prateekiiest commented 6 years ago

BTW , I have found another library to use jersey-client and following the API structure I feel its more easier