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
ca1b56c3
Commit
ca1b56c3
authored
Jun 03, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
ee24c4e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
PipelineServiceImpl.java
...cn/qg/holmes/service/gitlab/impl/PipelineServiceImpl.java
+2
-2
DingdingUtils.java
src/main/java/cn/qg/holmes/utils/DingdingUtils.java
+3
-2
JenkinsService.java
src/main/java/cn/qg/holmes/utils/JenkinsService.java
+6
-6
No files found.
src/main/java/cn/qg/holmes/service/gitlab/impl/PipelineServiceImpl.java
View file @
ca1b56c3
...
...
@@ -52,8 +52,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineMapper, Pipeline> i
if
(
pipeline
!=
null
)
{
if
(
pipeline
.
getEnable
()
==
1
)
{
log
.
info
(
"pipeline中找到对应项目,且项目是启动状态,开始构建:{}"
,
pipeline
.
toString
());
jenkinsService
.
buildJenkinsJob
(
pipeline
.
getServiceType
(),
projectName
,
branch
,
pipeline
.
getNamespace
());
String
markdown
=
DingdingUtils
.
buildPipelineMarkdownMsg
(
projectName
,
branch
,
author
,
message
,
commitDate
,
pipeline
.
getNamespace
());
Integer
buildNum
=
jenkinsService
.
buildJenkinsJob
(
pipeline
.
getServiceType
(),
projectName
,
branch
,
pipeline
.
getNamespace
());
String
markdown
=
DingdingUtils
.
buildPipelineMarkdownMsg
(
projectName
,
branch
,
pipeline
.
getServiceType
(),
author
,
message
,
commitDate
,
pipeline
.
getNamespace
(),
buildNum
.
toString
());
DingdingUtils
.
sendToDingding
(
markdown
,
dingRobotService
.
getById
(
pipeline
.
getDingRobotId
()).
getDingUrl
());
}
else
{
log
.
info
(
"pipeline中找到项目,但是项目状态为不启用,因此不构建!"
);
...
...
src/main/java/cn/qg/holmes/utils/DingdingUtils.java
View file @
ca1b56c3
...
...
@@ -166,7 +166,8 @@ public class DingdingUtils {
* @param namespace 环境
* @return
*/
public
static
String
buildPipelineMarkdownMsg
(
String
serviceName
,
String
serviceBranch
,
String
creator
,
String
commitMsg
,
String
date
,
String
namespace
)
{
public
static
String
buildPipelineMarkdownMsg
(
String
serviceName
,
String
serviceBranch
,
String
serviceType
,
String
creator
,
String
commitMsg
,
String
date
,
String
namespace
,
String
buildNum
)
{
String
title
=
"测试环境自动构建提醒"
;
String
content
=
"> 项目名称:"
+
serviceName
+
"\n\n"
+
"> 分支名称:"
+
serviceBranch
+
"\n\n"
...
...
@@ -174,7 +175,7 @@ public class DingdingUtils {
+
"> 触发同学:"
+
creator
+
"\n\n"
+
"> 触发信息:"
+
commitMsg
+
"\n\n"
+
"> 触发时间:"
+
date
+
"\n\n"
+
"[查看详情]("
+
"
"
+
")"
;
+
"[查看详情]("
+
"
http://172.29.1.15:8080/view/TKE/job/"
+
"tke-"
+
serviceType
+
"/"
+
buildNum
+
"/console"
+
")"
;
return
buildMarkdownMsg
(
title
,
content
,
false
);
}
...
...
src/main/java/cn/qg/holmes/utils/JenkinsService.java
View file @
ca1b56c3
...
...
@@ -52,19 +52,19 @@ public class JenkinsService {
* @param namespace 部署的环境
* @return
*/
public
void
buildJenkinsJob
(
String
type
,
String
project
,
String
branch
,
String
namespace
)
{
public
int
buildJenkinsJob
(
String
type
,
String
project
,
String
branch
,
String
namespace
)
{
Map
<
String
,
String
>
buildParams
=
new
HashMap
<>();
buildParams
.
put
(
"GIT_REPO"
,
project
);
buildParams
.
put
(
"BRANCH_NAME"
,
branch
);
buildParams
.
put
(
"DEPLOY"
,
"true"
);
buildParams
.
put
(
"NAMESPACE"
,
namespace
);
try
{
QueueReference
queueReference
=
jenkinsServer
.
getJob
(
"tke-"
+
type
).
build
(
buildParams
);
// Thread.sleep(5000);
Build
build
=
jenkinsServer
.
getBuild
(
jenkinsServer
.
getQueueItem
(
queueReference
));
System
.
out
.
println
(
build
.
getNumber
());
jenkinsServer
.
getJob
(
"tke-"
+
type
).
build
(
buildParams
);
Build
build
=
jenkinsServer
.
getJob
(
"tke-"
+
type
).
getLastBuild
();
return
build
.
getNumber
()
+
1
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
0
;
}
}
...
...
@@ -168,7 +168,7 @@ public class JenkinsService {
// System.out.println(buildResult);
// }
// System.out.println(userList.size());
jenkinsApi
.
buildJenkinsJob
(
"java"
,
"holmes"
,
"pipline"
,
"fe"
);
System
.
out
.
println
(
jenkinsApi
.
buildJenkinsJob
(
"ui"
,
"qa-platform-ui"
,
"xiaotong"
,
"fe"
)
);
}
}
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