Skip to content

Commit

Permalink
EasyCI. Use variables and url from request
Browse files Browse the repository at this point in the history
  • Loading branch information
znick committed Nov 4, 2024
1 parent f87b374 commit 2d081f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 10 additions & 2 deletions easyci2/flask/app/api/getExecResult.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
TASK_STATUSES = TTLCache(maxsize=1024, ttl=timedelta(minutes=15), timer=datetime.now)


def variables_raw2variables(variables_raw):
ret = {}
for v in variables_raw:
ret[v["key"]] = v["value"]
return ret


@bp.route('/gitlabci/', methods=['POST'])
def gitlabci():
gitlab_token_header = request.headers.get("X-Gitlab-Token")
Expand All @@ -38,15 +45,16 @@ def gitlabci():
job_id = job_data['id']

scheduler = GitlabCIScheduler()
variables = scheduler.get_pipeline_vars(pipeline_id)
variables_raw = pipeline_data["object_attributes"]["variables"]
variables = variables_raw2variables(variables_raw)

# init structure for message
ret = dict()

# set job data
ret["job_id"] = job_id
ret["timestamp"] = job_data["created_at"]
ret["pipeline_url"] = scheduler.get_pipeline(pipeline_id)["web_url"]
ret["pipeline_url"] = pipeline_data["object_attributes"]["url"]
ret["job_status"] = job_data["status"]

# set task data
Expand Down
1 change: 0 additions & 1 deletion easyci2/flask/app/easyCI/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def get_pipeline(self, pipeline_id):
def get_pipeline_vars(self, pipeline_id):
vars_raw = self._get_pipeline_vars_raw(pipeline_id)
# vars_raw = list of {"key" : <var_name>, "value" : <var_value>, ...}
get_var = lambda x: [i for i in vars_raw if i["key"] == x][0]["value"]
vars_new = dict()
for var in vars_raw:
vars_new[var["key"]] = var["value"]
Expand Down

0 comments on commit 2d081f1

Please sign in to comment.