Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-api
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
1
Merge Requests
1
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
qa-api
Commits
6ec2e20d
Commit
6ec2e20d
authored
Dec 10, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sonar FAILED
parent
ca01b49f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
pipeline.js
app/controller/pipeline.js
+1
-1
sonar.js
app/controller/sonar.js
+15
-13
No files found.
app/controller/pipeline.js
View file @
6ec2e20d
...
@@ -103,7 +103,7 @@ const webhooks = async function (ctx) {
...
@@ -103,7 +103,7 @@ const webhooks = async function (ctx) {
return
return
}
}
const
gitUser
=
req
.
user_username
const
gitUser
=
req
.
user_username
||
req
.
user_email
.
split
(
'
@
'
)[
0
]
const
commitMes
=
req
.
commits
[
req
.
commits
.
length
-
1
].
message
const
commitMes
=
req
.
commits
[
req
.
commits
.
length
-
1
].
message
// const project = await ProConfig.getOneProject({ project_name: projectName })
// const project = await ProConfig.getOneProject({ project_name: projectName })
...
...
app/controller/sonar.js
View file @
6ec2e20d
...
@@ -93,6 +93,11 @@ const callback = async (ctx) => {
...
@@ -93,6 +93,11 @@ const callback = async (ctx) => {
executionTimeMs
=
ceTaskResult
.
task
.
executionTimeMs
executionTimeMs
=
ceTaskResult
.
task
.
executionTimeMs
flag
=
false
flag
=
false
}
}
if
(
ceTaskResult
.
task
.
status
===
'
FAILED
'
)
{
executionTimeMs
=
ceTaskResult
.
task
.
executionTimeMs
data
.
sonarResult
=
ceTaskResult
.
task
.
status
flag
=
false
}
await
sleep
(
2
*
1000
)
await
sleep
(
2
*
1000
)
}
}
const
res
=
await
awaitRequest
({
const
res
=
await
awaitRequest
({
...
@@ -105,17 +110,11 @@ const callback = async (ctx) => {
...
@@ -105,17 +110,11 @@ const callback = async (ctx) => {
logger
.
info
(
data
.
projectName
,
'
触发质量阀,发送邮件通知
'
)
logger
.
info
(
data
.
projectName
,
'
触发质量阀,发送邮件通知
'
)
sendFailMail
(
data
,
i
,
executionTimeMs
)
sendFailMail
(
data
,
i
,
executionTimeMs
)
}
}
data
.
buildResult
=
'
success
'
data
.
sonarResult
=
i
.
status
.
qualityGateStatus
data
.
sonarResult
=
i
.
status
.
qualityGateStatus
data
.
analysisDate
=
i
.
analysisDate
data
.
analysisDate
=
i
.
analysisDate
// const sonarJob = await SonarJob.getOneSonarJob({ branchHash: data.branchHash })
// if (sonarJob) {
// await SonarJob.updateSonarJob(data)
// } else {
// await SonarJob.saveSonarJob(data)
// }
await
saveData
(
data
)
}
}
data
.
buildResult
=
'
success
'
await
saveData
(
data
)
ctx
.
body
=
ctx
.
ok
(
data
)
ctx
.
body
=
ctx
.
ok
(
data
)
}
}
...
@@ -142,6 +141,12 @@ const queryHandle = function (query) {
...
@@ -142,6 +141,12 @@ const queryHandle = function (query) {
}
else
{
}
else
{
delete
query
.
gitUser
delete
query
.
gitUser
}
}
if
(
query
.
startDate
)
{
Object
.
assign
(
query
,
{
createdAt
:
{
$gte
:
query
.
startDate
,
$lte
:
query
.
endDate
}
})
delete
query
.
startDate
delete
query
.
endDate
}
}
}
...
@@ -149,10 +154,7 @@ const getSonarJob = async (ctx) => {
...
@@ -149,10 +154,7 @@ const getSonarJob = async (ctx) => {
const
query
=
ctx
.
request
.
body
.
query
const
query
=
ctx
.
request
.
body
.
query
const
page
=
ctx
.
request
.
body
.
page
const
page
=
ctx
.
request
.
body
.
page
queryHandle
(
query
)
queryHandle
(
query
)
const
curDate
=
new
Date
()
const
data
=
await
SonarJob
.
getSonarJob
(
query
,
{
_id
:
0
},
{
createdAt
:
-
1
},
page
)
const
date
=
new
Date
(
curDate
.
getTime
()
-
3
*
24
*
60
*
60
*
1000
)
Object
.
assign
(
query
,
{
updatedAt
:
{
$gte
:
date
}
})
const
data
=
await
SonarJob
.
getSonarJob
(
query
,
{
_id
:
0
},
{
updatedAt
:
-
1
},
page
)
const
count
=
await
SonarJob
.
getSonarJobCount
(
query
)
const
count
=
await
SonarJob
.
getSonarJobCount
(
query
)
ctx
.
body
=
ctx
.
ok
({
data
,
count
})
ctx
.
body
=
ctx
.
ok
({
data
,
count
})
}
}
...
@@ -160,7 +162,7 @@ const getSonarJob = async (ctx) => {
...
@@ -160,7 +162,7 @@ const getSonarJob = async (ctx) => {
const
fetchQuality
=
async
(
ctx
)
=>
{
const
fetchQuality
=
async
(
ctx
)
=>
{
const
req
=
ctx
.
request
.
body
const
req
=
ctx
.
request
.
body
const
query
=
{
const
query
=
{
upd
atedAt
:
{
$gte
:
req
.
startDate
,
$lte
:
req
.
endDate
},
cre
atedAt
:
{
$gte
:
req
.
startDate
,
$lte
:
req
.
endDate
},
}
}
if
(
req
.
repository
)
{
if
(
req
.
repository
)
{
query
.
projectName
=
req
.
repository
query
.
projectName
=
req
.
repository
...
...
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