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
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
Show more breadcrumbs
Main Repositories
otb
Commits
29482a23
Commit
29482a23
authored
5 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
CI: fix cdash_handler, use env vars from Python for windows later
parent
0ebe000d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!621
Release 7.0 (master)
,
!504
CI: fix fast build
Pipeline
#1607
failed
5 years ago
Stage: precheck
Stage: external
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
.gitlab-ci.yml
CI/cdash_handler.py
+45
-12
45 additions, 12 deletions
CI/cdash_handler.py
with
47 additions
and
14 deletions
.gitlab-ci.yml
+
2
−
2
View file @
29482a23
...
...
@@ -39,7 +39,7 @@ fast-build:
-
git checkout -f -q $CI_COMMIT_SHA
-
python3 CI/check_twin_pipelines.py
after_script
:
-
python3 CI/cdash_handler.py
$CI_COMMIT_SHA $CI_PROJECT_ID $CI_PROJECT_DIR $K8S_SECRET_CDASH $CI_MERGE_REQUEST_REF_PATH
-
python3 CI/cdash_handler.py
script
:
-
ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-18.04-fast
-
ccache -s
...
...
@@ -56,7 +56,7 @@ fast-build:
# Checkout the expected branch
-
git checkout -f -q $CI_COMMIT_SHA
after_script
:
-
python3 CI/cdash_handler.py
$CI_COMMIT_SHA $CI_PROJECT_ID $CI_PROJECT_DIR $K8S_SECRET_CDASH $CI_MERGE_REQUEST_REF_PATH
-
python3 CI/cdash_handler.py
artifacts
:
when
:
on_failure
expire_in
:
24 hrs
...
...
This diff is collapsed.
Click to expand it.
CI/cdash_handler.py
+
45
−
12
View file @
29482a23
...
...
@@ -18,6 +18,7 @@
# limitations under the License.
#
import
os
import
os.path
import
urllib.request
import
urllib.parse
...
...
@@ -31,6 +32,16 @@ import time
trace
=
False
"""
Check needed environment parameters
"""
def
CheckEnvParameters
(
params
):
for
p
in
params
:
if
not
p
in
os
.
environ
.
keys
():
print
(
"
Missing environment variable
'"
+
p
+
"'"
)
return
False
return
True
class
Handler
:
# project
# site
...
...
@@ -239,20 +250,42 @@ site:"+site+", stamp:"+stamp+", name:"+name+", project:"+project+".")
return
(
state
,
errors
)
"""
TODO :
documentation, header, test if it is possible.
the script aims only at recovering the build url
This script aims only at recovering the build url
It uses environment variables setup by Gitlab Runner as default:
CI_COMMIT_SHA -> Commit SHA1
CI_PROJECT_ID -> Project ID
CI_PROJECT_DIR -> Project source directory
K8S_SECRET_API_TOKEN -> Token for Gitlab API
CI_MERGE_REQUEST_REF_PATH -> Ref name to push the status (only for merge request pipeline)
CI_COMMIT_REF_NAME -> Ref name to push the status
They can be overriden by a full command line :
cdash_handler.py commit_sha1 project_id project_directory token ref_name
"""
if
__name__
==
"
__main__
"
:
if
(
len
(
sys
.
argv
)
<
6
):
print
(
"
Usage :
"
+
sys
.
argv
[
0
]
+
"
commit_sha1 project_id
build
_directory token ref_name
"
)
sys
.
exit
()
if
(
len
(
sys
.
argv
)
<
6
and
len
(
sys
.
argv
)
>
1
):
print
(
"
Usage :
"
+
sys
.
argv
[
0
]
+
"
commit_sha1 project_id
project
_directory token ref_name
"
)
sys
.
exit
(
1
)
if
trace
:
print
(
sys
.
argv
)
if
(
len
(
sys
.
argv
)
>=
6
):
sha1
=
sys
.
argv
[
1
]
proj
=
sys
.
argv
[
2
]
pdir
=
sys
.
argv
[
3
]
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
'
]):
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
'
]
handler
=
Handler
()
build_dir
=
os
.
path
.
join
(
sys
.
argv
[
3
]
,
"
build/
"
)
ref_name
=
sys
.
argv
[
5
]
build_dir
=
os
.
path
.
join
(
pdir
,
"
build/
"
)
if
trace
:
print
(
"
build_dir is:
"
+
build_dir
)
handler
.
build_dir
=
build_dir
...
...
@@ -269,11 +302,11 @@ if __name__ == "__main__":
if
trace
:
print
(
"
cdash_url is:
"
+
cdash_url
)
gitlab_url
=
"
https://gitlab.orfeo-toolbox.org/api/v4/projects/
"
gitlab_url
+=
sys
.
argv
[
2
]
+
"
/statuses/
"
+
s
ys
.
argv
[
1
]
gitlab_url
+=
proj
+
"
/statuses/
"
+
s
ha1
params
=
urllib
.
parse
.
urlencode
({
'
name
'
:
'
cdash:
'
+
handler
.
site
,
'
state
'
:
state
,
\
'
target_url
'
:
cdash_url
,
'
description
'
:
error
,
'
ref
'
:
ref
_name
})
'
target_url
'
:
cdash_url
,
'
description
'
:
error
,
'
ref
'
:
ref
n
})
gitlab_request
=
urllib
.
request
.
Request
(
gitlab_url
)
gitlab_request
.
add_header
(
'
PRIVATE-TOKEN
'
,
sys
.
argv
[
4
]
)
gitlab_request
.
add_header
(
'
PRIVATE-TOKEN
'
,
token
)
res
=
urllib
.
request
.
urlopen
(
gitlab_request
,
data
=
params
.
encode
(
'
ascii
'
))
if
trace
:
print
(
"
gitlab_request.url:
"
+
gitlab_request
.
full_url
)
...
...
This diff is collapsed.
Click to expand it.
Guillaume Pasero
@gpasero
mentioned in merge request
!508 (merged)
·
5 years ago
mentioned in merge request
!508 (merged)
mentioned in merge request !508
Toggle commit list
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