增加生成后端服务代码。
This commit is contained in:
parent
394315f7f0
commit
8e4a9bb695
@ -30,7 +30,7 @@ public class JenkinsBuild extends Entity<Long> {
|
|||||||
@Column(name = "startTime", nullable = false)
|
@Column(name = "startTime", nullable = false)
|
||||||
private LocalDateTime starttime;
|
private LocalDateTime starttime;
|
||||||
|
|
||||||
@Column(name = "actions")
|
@Column(name = "actions", columnDefinition = "TEXT")
|
||||||
private String actions;
|
private String actions;
|
||||||
|
|
||||||
@Column(name = "external_system_id", nullable = false)
|
@Column(name = "external_system_id", nullable = false)
|
||||||
|
|||||||
@ -353,15 +353,22 @@ public class JenkinsServiceIntegration implements IJenkinsServiceIntegration {
|
|||||||
* @return 构建信息列表
|
* @return 构建信息列表
|
||||||
*/
|
*/
|
||||||
public List<JenkinsBuildResponse> listBuilds(ExternalSystem externalSystem, String jobName) {
|
public List<JenkinsBuildResponse> listBuilds(ExternalSystem externalSystem, String jobName) {
|
||||||
String treeQuery = "builds[number,url,result,timestamp,duration,building," +
|
String treeQuery = "builds[number,url,result,timestamp,duration,building,actions[_class,parameters[_class,name,value]]]";
|
||||||
"description,displayName,fullDisplayName,id,keepLog,queueId," +
|
List<JenkinsBuildResponse> builds = callJenkinsApi(
|
||||||
"actions[*],changeSets[*],artifacts[*]]";
|
|
||||||
return callJenkinsApi(
|
|
||||||
externalSystem,
|
externalSystem,
|
||||||
"/job/" + jobName + "/api/json",
|
"/job/" + jobName + "/api/json",
|
||||||
treeQuery,
|
treeQuery,
|
||||||
"builds",
|
"builds",
|
||||||
JenkinsBuildResponse.class
|
JenkinsBuildResponse.class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
String baseUrl = StringUtils.removeEnd(externalSystem.getUrl(), "/");
|
||||||
|
return builds.stream()
|
||||||
|
.peek(build -> {
|
||||||
|
if (build.getUrl() != null) {
|
||||||
|
build.setUrl(build.getUrl().replace(baseUrl, ""));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,10 +110,18 @@ public class JenkinsBuildResponse {
|
|||||||
public static class BuildParameter {
|
public static class BuildParameter {
|
||||||
@JsonProperty("_class")
|
@JsonProperty("_class")
|
||||||
private String type;
|
private String type;
|
||||||
private Map<String, String> parameters;
|
private List<Parameter> parameters;
|
||||||
private Map<String, Object> causes;
|
private Map<String, Object> causes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Parameter {
|
||||||
|
@JsonProperty("_class")
|
||||||
|
private String type;
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class ChangeSet {
|
public static class ChangeSet {
|
||||||
private String kind;
|
private String kind;
|
||||||
|
|||||||
@ -159,8 +159,7 @@ public class JenkinsBuildServiceImpl extends BaseServiceImpl<JenkinsBuild, Jenki
|
|||||||
// 4. 批量保存或更新
|
// 4. 批量保存或更新
|
||||||
jenkinsBuildRepository.saveAll(jenkinsBuilds);
|
jenkinsBuildRepository.saveAll(jenkinsBuilds);
|
||||||
|
|
||||||
log.info("Successfully synchronized {} Jenkins builds for job: {}",
|
log.info("Successfully synchronized {} Jenkins builds for job: {}", jenkinsBuilds.size(), jenkinsJob.getJobName());
|
||||||
jenkinsBuilds.size(), jenkinsJob.getJobName());
|
|
||||||
|
|
||||||
return jenkinsBuilds.size();
|
return jenkinsBuilds.size();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user