Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.admin
Commits
63778f91
Commit
63778f91
authored
7 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Automatically accept bob.conda merge requests if the pipeline succeeds
parent
b0bf6296
No related branches found
Branches containing commit
No related tags found
1 merge request
!54
Automatically accept bob.conda merge requests if the pipeline succeeds
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gitlab/update_feedstock.py
+30
-2
30 additions, 2 deletions
gitlab/update_feedstock.py
with
30 additions
and
2 deletions
gitlab/update_feedstock.py
+
30
−
2
View file @
63778f91
...
@@ -69,6 +69,7 @@ class Gitlab(object):
...
@@ -69,6 +69,7 @@ class Gitlab(object):
super
(
Gitlab
,
self
).
__init__
()
super
(
Gitlab
,
self
).
__init__
()
self
.
token
=
token
self
.
token
=
token
self
.
base_url
=
'
https://gitlab.idiap.ch/api/v3/
'
self
.
base_url
=
'
https://gitlab.idiap.ch/api/v3/
'
self
.
projects_url
=
self
.
base_url
+
'
projects/
'
def
get_project
(
self
,
project_name
,
namespace
=
'
bob
'
):
def
get_project
(
self
,
project_name
,
namespace
=
'
bob
'
):
cmd
=
[
"
curl
"
,
"
--header
"
,
cmd
=
[
"
curl
"
,
"
--header
"
,
...
@@ -112,6 +113,31 @@ class Gitlab(object):
...
@@ -112,6 +113,31 @@ class Gitlab(object):
pipeline
=
subprocess
.
check_output
(
cmd
)
pipeline
=
subprocess
.
check_output
(
cmd
)
return
json
.
loads
(
pipeline
.
decode
())
return
json
.
loads
(
pipeline
.
decode
())
def
accept_merge_request
(
self
,
project_id
,
mergerequest_id
,
merge_commit_message
=
None
,
should_remove_source_branch
=
None
,
merge_when_pipeline_succeeds
=
None
,
sha
=
None
):
"""
Update an existing merge request.
"""
data
=
{
'
merge_commit_message
'
:
merge_commit_message
,
'
should_remove_source_branch
'
:
should_remove_source_branch
,
'
merge_when_pipeline_succeeds
'
:
merge_when_pipeline_succeeds
,
'
sha
'
:
sha
,
}
request
=
requests
.
put
(
'
{0}/{1}/merge_request/{2}/merge
'
.
format
(
self
.
projects_url
,
project_id
,
mergerequest_id
),
data
=
data
,
headers
=
{
'
PRIVATE-TOKEN
'
:
self
.
token
})
if
request
.
status_code
==
200
:
return
request
.
json
()
else
:
return
False
def
update_meta
(
meta_path
,
package
):
def
update_meta
(
meta_path
,
package
):
stable_version
=
get_version
(
package
)
stable_version
=
get_version
(
package
)
...
@@ -220,8 +246,10 @@ def main(package, subfolder='recipes', direct_push=False):
...
@@ -220,8 +246,10 @@ def main(package, subfolder='recipes', direct_push=False):
gitlab
=
Gitlab
(
os
.
environ
.
get
(
'
GITLAB_API_TOKEN
'
))
gitlab
=
Gitlab
(
os
.
environ
.
get
(
'
GITLAB_API_TOKEN
'
))
project_id
=
gitlab
.
get_project
(
'
bob.conda
'
)[
'
id
'
]
project_id
=
gitlab
.
get_project
(
'
bob.conda
'
)[
'
id
'
]
title
=
'
Update-to-{}
'
.
format
(
branch_name
)
title
=
'
Update-to-{}
'
.
format
(
branch_name
)
gitlab
.
create_merge_request
(
project_id
,
branch_name
,
'
master
'
,
title
,
mr
=
gitlab
.
create_merge_request
(
project_id
,
branch_name
,
'
master
'
,
remove_source_branch
=
'
true
'
)
title
,
remove_source_branch
=
'
true
'
)
gitlab
.
accept_merge_request
(
project_id
,
mr
[
'
id
'
],
merge_when_pipeline_succeeds
=
'
true
'
)
finally
:
finally
:
shutil
.
rmtree
(
temp_dir
)
shutil
.
rmtree
(
temp_dir
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment