Commit 2ae50333 authored by Guillaume Pasero's avatar Guillaume Pasero

Merge branch 'ci_cdash_on_forks' into 'develop'

CI: fixing cdash links on forks

See merge request !558
parents e528ee35 20c503ca
Pipeline #2291 passed with stage
in 10 minutes and 44 seconds
...@@ -36,10 +36,11 @@ trace = False ...@@ -36,10 +36,11 @@ trace = False
""" """
Check needed environment parameters Check needed environment parameters
""" """
def CheckEnvParameters(params): def CheckEnvParameters(params, verbose=True):
for p in params: for p in params:
if not p in os.environ.keys(): if not p in os.environ.keys():
print("Missing environment variable '"+p+"'") if verbose:
print("Missing environment variable '"+p+"'")
return False return False
return True return True
...@@ -255,12 +256,13 @@ if __name__ == "__main__": ...@@ -255,12 +256,13 @@ if __name__ == "__main__":
if not CheckEnvParameters(['CI_COMMIT_SHA', 'CI_PROJECT_ID', 'CI_PROJECT_DIR', 'CI_COMMIT_REF_NAME']): if not CheckEnvParameters(['CI_COMMIT_SHA', 'CI_PROJECT_ID', 'CI_PROJECT_DIR', 'CI_COMMIT_REF_NAME']):
sys.exit(1) sys.exit(1)
sha1 = os.environ['CI_COMMIT_SHA'] sha1 = os.environ['CI_COMMIT_SHA']
refn = os.environ['CI_COMMIT_REF_NAME']
proj = os.environ['CI_PROJECT_ID'] proj = os.environ['CI_PROJECT_ID']
pdir = os.environ['CI_PROJECT_DIR'] pdir = os.environ['CI_PROJECT_DIR']
if 'CI_MERGE_REQUEST_REF_PATH' in os.environ.keys(): if CheckEnvParameters(['CI_MERGE_REQUEST_REF_PATH', 'CI_MERGE_REQUEST_PROJECT_ID'], verbose=False):
refn = os.environ['CI_MERGE_REQUEST_REF_PATH'] targetProj = os.environ['CI_MERGE_REQUEST_PROJECT_ID']
else: if proj == targetProj:
refn = os.environ['CI_COMMIT_REF_NAME'] refn = os.environ['CI_MERGE_REQUEST_REF_PATH']
if CheckEnvParameters(['K8S_SECRET_API_TOKEN']): if CheckEnvParameters(['K8S_SECRET_API_TOKEN']):
token = os.environ['K8S_SECRET_API_TOKEN'] token = os.environ['K8S_SECRET_API_TOKEN']
else: else:
...@@ -288,7 +290,8 @@ if __name__ == "__main__": ...@@ -288,7 +290,8 @@ if __name__ == "__main__":
'target_url' : cdash_url , 'description' : error , 'ref' : refn }) 'target_url' : cdash_url , 'description' : error , 'ref' : refn })
gitlab_request = urllib.request.Request(gitlab_url) gitlab_request = urllib.request.Request(gitlab_url)
gitlab_request.add_header('PRIVATE-TOKEN' , token ) gitlab_request.add_header('PRIVATE-TOKEN' , token )
res = urllib.request.urlopen(gitlab_request, data=params.encode('ascii'))
if trace: if trace:
print ("gitlab_request.url: " + gitlab_request.full_url) print ("gitlab_request.url: " + gitlab_request.full_url)
res = urllib.request.urlopen(gitlab_request, data=params.encode('ascii'))
if trace:
print ("gitlab_request.text: " + res.read().decode()) print ("gitlab_request.text: " + res.read().decode())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment