Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
Julien Cabieces
otb
Commits
1624d75e
Commit
1624d75e
authored
5 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
CI: make API token optional
parent
1ecafba8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CI/cdash_handler.py
+8
-4
8 additions, 4 deletions
CI/cdash_handler.py
CI/check_twin_pipelines.py
+4
-3
4 additions, 3 deletions
CI/check_twin_pipelines.py
with
12 additions
and
7 deletions
CI/cdash_handler.py
+
8
−
4
View file @
1624d75e
...
...
@@ -302,16 +302,19 @@ if __name__ == "__main__":
token
=
sys
.
argv
[
4
]
refn
=
sys
.
argv
[
5
]
else
:
if
not
CheckEnvParameters
([
'
CI_COMMIT_SHA
'
,
'
CI_PROJECT_ID
'
,
'
CI_PROJECT_DIR
'
,
'
K8S_SECRET_API_TOKEN
'
,
'
CI_COMMIT_REF_NAME
'
]):
if
not
CheckEnvParameters
([
'
CI_COMMIT_SHA
'
,
'
CI_PROJECT_ID
'
,
'
CI_PROJECT_DIR
'
,
'
CI_COMMIT_REF_NAME
'
]):
sys
.
exit
(
1
)
sha1
=
os
.
environ
[
'
CI_COMMIT_SHA
'
]
proj
=
os
.
environ
[
'
CI_PROJECT_ID
'
]
pdir
=
os
.
environ
[
'
CI_PROJECT_DIR
'
]
token
=
os
.
environ
[
'
K8S_SECRET_API_TOKEN
'
]
if
'
CI_MERGE_REQUEST_REF_PATH
'
in
os
.
environ
.
keys
():
refn
=
os
.
environ
[
'
CI_MERGE_REQUEST_REF_PATH
'
]
else
:
refn
=
os
.
environ
[
'
CI_COMMIT_REF_NAME
'
]
if
CheckEnvParameters
([
'
K8S_SECRET_API_TOKEN
'
]):
token
=
os
.
environ
[
'
K8S_SECRET_API_TOKEN
'
]
else
:
token
=
None
handler
=
Handler
()
build_dir
=
os
.
path
.
join
(
pdir
,
"
build/
"
)
if
trace
:
...
...
@@ -327,8 +330,9 @@ if __name__ == "__main__":
else
:
cdash_url
=
handler
.
GetBuildUrl
()
(
state
,
error
)
=
handler
.
GetLogStatus
(
os
.
path
.
join
(
pdir
,
"
log
"
)
)
if
trace
:
print
(
"
cdash_url is:
"
+
cdash_url
)
print
(
"
CDash build URL :
"
+
cdash_url
)
if
token
is
None
:
sys
.
exit
(
0
)
gitlab_url
=
"
https://gitlab.orfeo-toolbox.org/api/v4/projects/
"
gitlab_url
+=
proj
+
"
/statuses/
"
+
sha1
params
=
urllib
.
parse
.
urlencode
({
'
name
'
:
'
cdash:
'
+
handler
.
site
,
'
state
'
:
state
,
\
...
...
This diff is collapsed.
Click to expand it.
CI/check_twin_pipelines.py
+
4
−
3
View file @
1624d75e
...
...
@@ -65,9 +65,10 @@ if __name__ == "__main__":
# are we in a merge_request pipeline ?
if
'
CI_MERGE_REQUEST_IID
'
in
env
.
keys
():
if
not
CheckEnvParameters
([
'
K8S_SECRET_API_TOKEN
'
]):
print
(
"
Make sure you have set a valid acces token for Gitlab API
"
)
print
(
"
The K8S_SECRET_API_TOKEN environment variable should be set in
'
Settings -> CI/CD -> Variables
'"
)
sys
.
exit
(
1
)
print
(
"
WARNING: Make sure you have set a valid acces token for Gitlab API.
"
\
+
"
The K8S_SECRET_API_TOKEN environment variable should be set in
'
Settings -> CI/CD -> Variables
'"
\
+
"
Without this token, some feature of the CI platform will be disabled.
"
)
sys
.
exit
(
0
)
if
not
CheckEnvParameters
([
'
CI_PROJECT_ID
'
,
'
CI_PIPELINE_ID
'
]):
sys
.
exit
(
1
)
mrInfo
=
GitlabRequest
(
'
merge_requests/
'
+
env
[
'
CI_MERGE_REQUEST_IID
'
],
token
=
env
[
'
K8S_SECRET_API_TOKEN
'
])
...
...
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