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
Merge requests
!26
Add a script that can work as nightlies
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add a script that can work as nightlies
nightlies
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Amir MOHAMMADI
requested to merge
nightlies
into
master
8 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
master
version 1
741cb293
8 years ago
master (base)
and
latest version
latest version
ef3b6ec1
1 commit,
8 years ago
version 1
741cb293
1 commit,
8 years ago
1 file
+
118
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
nightlies/trigger_pipelines.py
0 → 100755
+
118
−
0
Options
#!/usr/bin/env python
"""
Trigger Pipelines.
You need to set the environment variable of
GITLAB_API_TOKEN to your private token
Usage:
{0} <project_name>...
{0} -h | --help
{0} --version
Options:
-h --help Show this screen.
--version Show version.
"""
import
os
import
sys
import
subprocess
import
json
import
time
from
docopt
import
docopt
PACKAGES_ID
=
{
'
bob.extension
'
:
'
1475
'
,
'
bob.blitz
'
:
'
1390
'
,
'
bob.core
'
:
'
1394
'
,
'
bob.ip.draw
'
:
'
1491
'
,
'
bob.io.base
'
:
'
1479
'
,
'
bob.sp
'
:
'
1527
'
,
'
bob.math
'
:
'
1540
'
,
'
bob.ap
'
:
'
1377
'
,
'
bob.measure
'
:
'
1521
'
,
'
bob.db.base
'
:
'
1409
'
,
'
bob.io.image
'
:
'
1481
'
,
'
bob.io.video
'
:
'
1485
'
,
'
bob.io.matlab
'
:
'
1483
'
,
'
bob.ip.base
'
:
'
1487
'
,
'
bob.ip.color
'
:
'
1488
'
,
'
bob.ip.gabor
'
:
'
1497
'
,
'
bob.learn.activation
'
:
'
1506
'
,
'
bob.learn.libsvm
'
:
'
1512
'
,
'
bob.learn.boosting
'
:
'
1509
'
,
'
bob.io.audio
'
:
'
1477
'
,
'
bob.learn.linear
'
:
'
1514
'
,
'
bob.learn.mlp
'
:
'
1517
'
,
'
bob.db.wine
'
:
'
1468
'
,
'
bob.db.mnist
'
:
'
1440
'
,
'
bob.db.atnt
'
:
'
1399
'
,
'
bob.ip.flandmark
'
:
'
1495
'
,
'
bob.ip.facedetect
'
:
'
1493
'
,
'
bob.ip.optflow.hornschunck
'
:
'
1500
'
,
'
bob.ip.optflow.liu
'
:
'
1503
'
,
'
bob.learn.em
'
:
'
1510
'
,
'
bob.db.iris
'
:
'
1431
'
,
}
class
Gitlab
(
object
):
"""
A class that wraps Gitlab API using curl
"""
def
__init__
(
self
,
token
):
super
(
Gitlab
,
self
).
__init__
()
self
.
token
=
token
self
.
base_url
=
'
https://gitlab.idiap.ch/api/v3/
'
def
get_project
(
self
,
project_name
,
namespace
=
'
bob
'
):
cmd
=
[
"
curl
"
,
"
--header
"
,
"
PRIVATE-TOKEN: {}
"
.
format
(
self
.
token
),
self
.
base_url
+
"
projects/{}%2F{}
"
.
format
(
namespace
,
project_name
)]
pipeline
=
subprocess
.
check_output
(
cmd
)
return
json
.
loads
(
pipeline
.
decode
())
def
create_pipeline
(
self
,
project_id
):
cmd
=
[
"
curl
"
,
"
--request
"
,
"
POST
"
,
"
--header
"
,
"
PRIVATE-TOKEN: {}
"
.
format
(
self
.
token
),
self
.
base_url
+
"
projects/{}/pipeline?ref=master
"
.
format
(
project_id
)]
pipeline
=
subprocess
.
check_output
(
cmd
)
return
json
.
loads
(
pipeline
.
decode
())
def
get_pipeline
(
self
,
project_id
,
pipeline_id
):
cmd
=
[
"
curl
"
,
"
--header
"
,
"
PRIVATE-TOKEN: {}
"
.
format
(
self
.
token
),
self
.
base_url
+
"
projects/{}/pipelines/{}
"
.
format
(
project_id
,
pipeline_id
)]
pipeline
=
subprocess
.
check_output
(
cmd
)
return
json
.
loads
(
pipeline
.
decode
())
def
main
(
packages_list
):
gitlab
=
Gitlab
(
os
.
environ
.
get
(
'
GITLAB_API_TOKEN
'
))
for
package
in
packages_list
:
pid
=
PACKAGES_ID
.
get
(
package
)
if
pid
is
None
:
pid
=
gitlab
.
get_project
(
package
)[
'
id
'
]
print
(
'
Triggering a pipeline for {}
'
.
format
(
package
))
last_pipeline
=
gitlab
.
create_pipeline
(
pid
)
while
last_pipeline
[
'
status
'
]
in
[
'
pending
'
,
'
running
'
]:
print
(
'
Pipeline {} for project {} is not finished.
'
'
Sleeping for 30 seconds.
'
.
format
(
last_pipeline
[
'
id
'
],
package
))
time
.
sleep
(
30
)
last_pipeline
=
gitlab
.
get_pipeline
(
pid
,
last_pipeline
[
'
id
'
])
if
not
last_pipeline
[
'
status
'
]
==
'
passed
'
:
print
(
'
Pipeline {} for project {} failed. Exiting ...
'
.
format
(
last_pipeline
[
'
id
'
],
package
))
return
if
__name__
==
'
__main__
'
:
arguments
=
docopt
(
__doc__
.
format
(
sys
.
argv
[
0
]),
version
=
'
Nightlies 0.0.1
'
)
print
(
arguments
)
main
(
arguments
[
'
<project_name>
'
])
Loading