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