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
cf7774bb
Commit
cf7774bb
authored
Dec 10, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sonar FAILED
parent
6ec2e20d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
24 deletions
+22
-24
sonar.js
app/controller/sonar.js
+22
-24
No files found.
app/controller/sonar.js
View file @
cf7774bb
...
@@ -90,29 +90,31 @@ const callback = async (ctx) => {
...
@@ -90,29 +90,31 @@ const callback = async (ctx) => {
logger
.
info
(
data
.
projectName
,
data
.
branchName
,
data
.
branchHash
,
'
的分析任务执行信息:
'
,
ceTaskResult
.
task
.
status
,
ceTaskResult
)
logger
.
info
(
data
.
projectName
,
data
.
branchName
,
data
.
branchHash
,
'
的分析任务执行信息:
'
,
ceTaskResult
.
task
.
status
,
ceTaskResult
)
if
(
ceTaskResult
.
task
.
status
===
'
SUCCESS
'
)
{
if
(
ceTaskResult
.
task
.
status
===
'
SUCCESS
'
)
{
executionTimeMs
=
ceTaskResult
.
task
.
executionTimeMs
flag
=
false
flag
=
false
executionTimeMs
=
ceTaskResult
.
task
.
executionTimeMs
const
res
=
await
awaitRequest
({
url
:
`
${
config
.
sonarHost
}
/api/project_branches/list?project=
${
data
.
projectName
}
`
,
method
:
'
GET
'
,
})
logger
.
info
(
'
analysisResult
'
,
data
.
projectName
,
JSON
.
stringify
(
res
))
for
(
const
i
of
res
.
branches
)
{
if
(
i
.
name
===
'
master
'
&&
i
.
status
.
qualityGateStatus
!==
'
OK
'
&&
data
.
mail
!==
'
noMail
'
)
{
logger
.
info
(
data
.
projectName
,
'
触发质量阀,发送邮件通知
'
)
sendFailMail
(
data
,
i
,
executionTimeMs
)
}
data
.
sonarResult
=
i
.
status
.
qualityGateStatus
data
.
analysisDate
=
i
.
analysisDate
}
}
}
if
(
ceTaskResult
.
task
.
status
===
'
FAILED
'
)
{
if
(
ceTaskResult
.
task
.
status
===
'
FAILED
'
)
{
executionTimeMs
=
ceTaskResult
.
task
.
executionTimeMs
data
.
sonarResult
=
ceTaskResult
.
task
.
status
flag
=
false
flag
=
false
data
.
sonarResult
=
ceTaskResult
.
task
.
status
Object
.
assign
(
data
,
{
error
:
ceTaskResult
.
task
.
errorMessage
})
sendExceptionMail
(
data
)
}
}
await
sleep
(
2
*
1000
)
await
sleep
(
2
*
1000
)
}
}
const
res
=
await
awaitRequest
({
url
:
`
${
config
.
sonarHost
}
/api/project_branches/list?project=
${
data
.
projectName
}
`
,
method
:
'
GET
'
,
})
logger
.
info
(
'
analysisResult
'
,
data
.
projectName
,
JSON
.
stringify
(
res
))
for
(
const
i
of
res
.
branches
)
{
if
(
i
.
name
===
'
master
'
&&
i
.
status
.
qualityGateStatus
!==
'
OK
'
&&
data
.
mail
!==
'
noMail
'
)
{
logger
.
info
(
data
.
projectName
,
'
触发质量阀,发送邮件通知
'
)
sendFailMail
(
data
,
i
,
executionTimeMs
)
}
data
.
sonarResult
=
i
.
status
.
qualityGateStatus
data
.
analysisDate
=
i
.
analysisDate
}
data
.
buildResult
=
'
success
'
data
.
buildResult
=
'
success
'
await
saveData
(
data
)
await
saveData
(
data
)
ctx
.
body
=
ctx
.
ok
(
data
)
ctx
.
body
=
ctx
.
ok
(
data
)
...
@@ -160,13 +162,9 @@ const getSonarJob = async (ctx) => {
...
@@ -160,13 +162,9 @@ const getSonarJob = async (ctx) => {
}
}
const
fetchQuality
=
async
(
ctx
)
=>
{
const
fetchQuality
=
async
(
ctx
)
=>
{
const
req
=
ctx
.
request
.
body
const
query
=
ctx
.
request
.
body
const
query
=
{
queryHandle
(
query
)
createdAt
:
{
$gte
:
req
.
startDate
,
$lte
:
req
.
endDate
},
}
if
(
req
.
repository
)
{
query
.
projectName
=
req
.
repository
}
// const data = await SonarJob.getSonarJobGroup(query);
// const data = await SonarJob.getSonarJobGroup(query);
let
data
=
await
SonarJob
.
getSonarJob
(
query
,
{
let
data
=
await
SonarJob
.
getSonarJob
(
query
,
{
...
@@ -201,7 +199,7 @@ const fetchQuality = async (ctx) => {
...
@@ -201,7 +199,7 @@ const fetchQuality = async (ctx) => {
for
(
const
i
in
data
)
{
for
(
const
i
in
data
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
data
,
i
))
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
data
,
i
))
{
res
.
push
({
res
.
push
({
repository
:
i
,
projectName
:
i
,
success
:
data
[
i
].
success
,
success
:
data
[
i
].
success
,
fail
:
data
[
i
].
fail
,
fail
:
data
[
i
].
fail
,
exception
:
data
[
i
].
exception
,
exception
:
data
[
i
].
exception
,
...
...
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