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
46d0c0bc
Commit
46d0c0bc
authored
Dec 20, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化获取分支
parent
220b9128
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
pipeline.js
app/controller/pipeline.js
+3
-3
PipeLine.js
app/model/mongo/qa_api/PipeLine.js
+3
-3
No files found.
app/controller/pipeline.js
View file @
46d0c0bc
...
@@ -148,7 +148,7 @@ const gitBranch = async (svcName) => {
...
@@ -148,7 +148,7 @@ const gitBranch = async (svcName) => {
const
version
=
proConfig
.
git_lab
===
'
gitabc.xyqb.com
'
?
'
v3
'
:
'
v4
'
const
version
=
proConfig
.
git_lab
===
'
gitabc.xyqb.com
'
?
'
v3
'
:
'
v4
'
const
token
=
config
.
gitlab
.
token
const
token
=
config
.
gitlab
.
token
const
data
=
await
awaitRequest
({
const
data
=
await
awaitRequest
({
url
:
`http://
${
proConfig
.
git_lab
}
/api/
${
version
}
/projects?per_page=200&search=
${
svcName
}
&private_token=
${
token
}
`
,
url
:
`http://
${
proConfig
.
git_lab
}
/api/
${
version
}
/projects?per_page=200&search=
${
svcName
}
&private_token=
${
token
}
&simple=true
`
,
method
:
'
GET
'
,
method
:
'
GET
'
,
})
})
if
(
data
.
length
===
0
)
{
if
(
data
.
length
===
0
)
{
...
@@ -170,7 +170,7 @@ const gitBranch = async (svcName) => {
...
@@ -170,7 +170,7 @@ const gitBranch = async (svcName) => {
}
}
const
getGitBranch
=
async
function
(
ctx
)
{
const
getGitBranch
=
async
function
(
ctx
)
{
const
{
name
}
=
ctx
.
request
.
bod
y
const
{
name
}
=
ctx
.
request
.
quer
y
const
branchInfo
=
await
gitBranch
(
name
)
const
branchInfo
=
await
gitBranch
(
name
)
if
(
branchInfo
.
length
===
0
)
{
if
(
branchInfo
.
length
===
0
)
{
ctx
.
body
=
ctx
.
fail
(
'
无拉去此项目的权限
'
)
ctx
.
body
=
ctx
.
fail
(
'
无拉去此项目的权限
'
)
...
@@ -334,7 +334,7 @@ const router = new Router()
...
@@ -334,7 +334,7 @@ const router = new Router()
router
router
.
use
(
bodyParser
())
.
use
(
bodyParser
())
.
post
(
'
/save
'
,
save
)
.
post
(
'
/save
'
,
save
)
.
post
(
'
/master
'
,
getGitBranch
)
.
get
(
'
/getGitBranch
'
,
getGitBranch
)
.
post
(
'
/find
'
,
findPipes
)
.
post
(
'
/find
'
,
findPipes
)
.
post
(
'
/webhooks
'
,
webhooks
)
.
post
(
'
/webhooks
'
,
webhooks
)
.
post
(
'
/delete
'
,
deletePipes
)
.
post
(
'
/delete
'
,
deletePipes
)
...
...
app/model/mongo/qa_api/PipeLine.js
View file @
46d0c0bc
...
@@ -14,7 +14,6 @@ const schema = new Schema({
...
@@ -14,7 +14,6 @@ const schema = new Schema({
noticeAddress
:
{
type
:
String
},
noticeAddress
:
{
type
:
String
},
noticeType
:
{
type
:
String
},
noticeType
:
{
type
:
String
},
update_user
:
{
type
:
String
},
update_user
:
{
type
:
String
},
create_time
:
{
type
:
String
},
des
:
{
type
:
String
},
des
:
{
type
:
String
},
},
{
},
{
versionKey
:
false
,
versionKey
:
false
,
...
@@ -23,6 +22,7 @@ const schema = new Schema({
...
@@ -23,6 +22,7 @@ const schema = new Schema({
})
})
schema
.
statics
.
savePipes
=
function
(
doc
)
{
schema
.
statics
.
savePipes
=
function
(
doc
)
{
if
(
doc
.
_id
)
{
if
(
doc
.
_id
)
{
delete
doc
.
updatedAt
return
this
.
updateOne
({
return
this
.
updateOne
({
_id
:
doc
.
_id
,
_id
:
doc
.
_id
,
},
doc
)
},
doc
)
...
@@ -32,10 +32,10 @@ schema.statics.savePipes = function (doc) {
...
@@ -32,10 +32,10 @@ schema.statics.savePipes = function (doc) {
schema
.
statics
.
getPipes
=
function
(
data
)
{
schema
.
statics
.
getPipes
=
function
(
data
)
{
data
.
application_name
=
new
RegExp
(
data
.
application_name
)
data
.
application_name
=
new
RegExp
(
data
.
application_name
)
data
.
new_user
=
new
RegExp
(
data
.
new_user
)
data
.
new_user
=
new
RegExp
(
data
.
new_user
)
return
this
.
find
(
data
).
sort
({
cre
atedAt
:
-
1
})
return
this
.
find
(
data
).
sort
({
upd
atedAt
:
-
1
})
}
}
schema
.
statics
.
getMatchPipe
=
function
(
name
)
{
schema
.
statics
.
getMatchPipe
=
function
(
name
)
{
return
this
.
find
({
repos
:
{
$elemMatch
:
{
repository
:
name
}
}
}).
sort
({
cre
atedAt
:
1
})
return
this
.
find
({
repos
:
{
$elemMatch
:
{
repository
:
name
}
}
}).
sort
({
upd
atedAt
:
1
})
}
}
schema
.
statics
.
delete
=
function
(
id
)
{
schema
.
statics
.
delete
=
function
(
id
)
{
return
this
.
findByIdAndRemove
(
id
)
return
this
.
findByIdAndRemove
(
id
)
...
...
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