Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
holmes
Commits
26a39d09
Commit
26a39d09
authored
Sep 02, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增build信息查询结果
parent
a20571a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
DbSyncController.java
...java/cn/qg/holmes/controller/effect/DbSyncController.java
+11
-0
JenkinsService.java
src/main/java/cn/qg/holmes/utils/JenkinsService.java
+12
-4
No files found.
src/main/java/cn/qg/holmes/controller/effect/DbSyncController.java
View file @
26a39d09
...
...
@@ -101,4 +101,15 @@ public class DbSyncController {
return
JsonResult
.
buildSuccessResult
(
"开始同步数据库!"
,
true
);
}
}
@GetMapping
(
"/query"
)
public
JsonResult
queryDbSyncResult
(
String
jobName
,
int
buildNum
)
{
try
{
Map
<
String
,
String
>
result
=
jenkinsService
.
getBuildInfo
(
jobName
,
buildNum
);
return
JsonResult
.
buildSuccessResult
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JsonResult
.
buildErrorStateResult
(
"查询失败"
,
false
);
}
}
}
src/main/java/cn/qg/holmes/utils/JenkinsService.java
View file @
26a39d09
...
...
@@ -2,9 +2,7 @@ package cn.qg.holmes.utils;
import
com.offbytwo.jenkins.JenkinsServer
;
import
com.offbytwo.jenkins.client.JenkinsHttpClient
;
import
com.offbytwo.jenkins.model.Build
;
import
com.offbytwo.jenkins.model.Job
;
import
com.offbytwo.jenkins.model.JobWithDetails
;
import
com.offbytwo.jenkins.model.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
...
...
@@ -177,6 +175,15 @@ public class JenkinsService {
}
}
public
Map
<
String
,
String
>
getBuildInfo
(
String
jobName
,
int
buildNum
)
throws
IOException
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
JobWithDetails
job
=
jenkinsServer
.
getJob
(
jobName
);
Build
build
=
job
.
getBuildByNumber
(
buildNum
);
result
.
put
(
"status"
,
build
.
details
().
getResult
().
toString
());
result
.
put
(
"text"
,
build
.
details
().
getConsoleOutputText
());
return
result
;
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
JenkinsService
jenkinsApi
=
new
JenkinsService
();
// List<Build> buildList = jenkinsApi.getJobBuildList("tke-java", 1, "kdsp");
...
...
@@ -190,7 +197,8 @@ public class JenkinsService {
// System.out.println(buildResult);
// }
// System.out.println(userList.size());
System
.
out
.
println
(
jenkinsApi
.
buildJenkinsJob
(
"ui"
,
"qa-platform-ui"
,
"xiaotong"
,
"fe"
));
// System.out.println(jenkinsApi.buildJenkinsJob("ui", "qa-platform-ui", "xiaotong", "fe"));
System
.
out
.
println
(
jenkinsApi
.
getBuildInfo
(
"sync_database_schema"
,
13237
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment