GitFlic + EvaProject
Preparation and Setup
To link your GitFlic project with EvaProject, you need to configure webhook reception on the EvaProject side and handle incoming webhooks triggered by events in your GitFlic project.
First, you will need to gather the necessary data to ensure correct webhook delivery from GitFlic. Refer to the EvaProject documentation to learn where to create code for working with webhooks, as well as how to create a token that must be used when sending webhooks.
The EvaProject documentation page is available at this link
Template for the URL to which the webhook should be sent:
https://<domain>/pub/webhook?name=<id>&token=<token>
Field | Type | Description |
---|---|---|
domain |
String | The domain where EvaProject is hosted |
id |
String | Webhook code, can be found in the list of webhooks or in the webhook settings |
token |
String | Token required for signing webhooks |
Script Example
A script of type bzPython
changes the task status depending on the status of the merge request. The link is set up by the name of the merge request.
Status MR in incoming GitFlic webhook | EvaProject task status |
---|---|
MERGE_REQUEST_CREATE or MERGE_REQUEST_UPDATE |
in review |
MERGE_REQUEST_CANCEL or MERGE_REQUEST_CLOSE |
fail |
MERGE |
closed |
data = json.loads(my_json)
tasks = models.CmfTask.list()
for task in tasks:
# find the task (branch name must match the task name)
if (task.name == data['merge_request']['source_branch']):
# handle merge-request creation
if (data['action'] == 'MERGE_REQUEST_CREATE'):
status = 'in_review'
# handle merge-request update
elif (data['action'] == 'MERGE_REQUEST_UPDATE'):
status = 'in_review'
# handle merge-request cancellation
elif (data['action'] == 'MERGE_REQUEST_CANCEL'):
status = 'fail'
# handle merge-request closure
elif (data['action'] == 'MERGE_REQUEST_CLOSE'):
status = 'fail'
# handle merge-request merge
elif (data['action'] == 'MERGE'):
status = 'closed'
else:
status = 'open'
# save the task
task.status = task.workflow.get_default_status(status_code=status)
task.save()
See articles on working with GitFlic webhooks
Automated translation!
This page was translated using automatic translation tools. The text may contain inaccuracies.