maven仓库:https://mvnrepository.com/artifact/io.github.cdancy/jenkins-rest/1.0.2
添加pom依赖:
<!-- https://mvnrepository.com/artifact/io.github.cdancy/jenkins-rest -->
<dependency>
<groupId>io.github.cdancy</groupId>
<artifactId>jenkins-rest</artifactId>
<version>1.0.2</version>
</dependency>
使用:
JenkinsClient client = JenkinsClient.builder()
.endPoint("http://127.0.0.1:8080") // Optional. Defaults to http://127.0.0.1:8080
.credentials("admin:password") // Optional. 或者使用"admin:token"
.build();
SystemInfo systemInfo = client.api().systemApi().systemInfo();
Map<String, List<String>> params = new HashMap<>();
String finalJobName = "测试";
// 触发参数化构建
Integer queueId = client .api().jobsApi()
.buildWithParameters(null, finalJobName, params )
.value();