Commit 1d88c920 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

CI: can't make the data option to work properly, find an other way

No related merge requests found
Showing with 6 additions and 8 deletions
+6 -8
......@@ -29,16 +29,14 @@ import time
Send a request to Gitlab and return the answer
The request parameter is added after `project/:id/`
"""
def GitlabRequest(request, project=53,data={}, token=''):
def GitlabRequest(request, project=53, token=''):
gitlab_url = "https://gitlab.orfeo-toolbox.org/api/v4/projects/"
gitlab_url+= str(project) + '/' + request
params = None
if data:
params = urllib.parse.urlencode(data).encode('ascii')
gitlab_request = urllib.request.Request(gitlab_url)
myHeader = {}
if token:
gitlab_request.add_header('PRIVATE-TOKEN' , token )
res = urllib.request.urlopen(gitlab_request, data=params)
myHeader = {'PRIVATE-TOKEN':token}
gitlab_request = urllib.request.Request(gitlab_url,headers=myHeader)
res = urllib.request.urlopen(gitlab_request)
return json.loads(res.read().decode())
"""
......@@ -76,7 +74,7 @@ if __name__ == "__main__":
sys.exit(1)
else:
# No: cancel any previous "normal" pipeline on the same SHA1
jres = GitlabRequest('pipelines', project=env['CI_PROJECT_ID'], data={'sha':sha1}, token=env['K8S_SECRET_TWIN_PIPELINE'])
jres = GitlabRequest('pipelines?sha='+sha1, project=env['CI_PROJECT_ID'], token=env['K8S_SECRET_TWIN_PIPELINE'])
for item in jres:
if item["id"] < int(env['CI_PIPELINE_ID']) and item["status"] == "running":
print("Cancel pipeline "+str(item["id"]))
......
Supports Markdown
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