pipelines-as-code icon indicating copy to clipboard operation
pipelines-as-code copied to clipboard

RFE: support {{pull_request_number}} for `push` events when PR/MR merges

Open concaf opened this issue 2 years ago • 1 comments

as per https://pipelinesascode.com/docs/guide/authoringprs/,

{{pull_request_number}}: The pull or merge request number, only defined when we are in a pull_request event type.

i'd like to know the PR/MR a given push event is linked to - it can be set to null or left unset (current behavior) if it's not linked to any PR/MR, but if it is, i'd love to see that info in {{pull_request_number}} variable.

one could argue that this is technically incorrect, but intuitively, i expect the PR/MR number to be present in the push event as well.

today, i've written a task that looks up the MR ID from commit SHA directly via gitlab API as a workaround:

API_URL="https://<gitlab host>/api/v4/projects/<project id>/repository/commits/{{ revision }}/merge_requests/?format=json"
      iid=$(curl -s -k $API_URL | jq .[0].iid)
      [ $iid == "null" ] && echo "commit is not coming from a merge request?"
      echo -n "$iid" | tee  $(results.mr-id.path)

and i believe this is possible via github API as well.

WDYT about this RFE? does it make sense?

concaf avatar Jul 21 '23 11:07 concaf

we looked at this some time ago for github and there is no proper API for this on github to be able to do this, they do have it on the UI but that is not exposed.

we can perhaps do this on other vcs provider like gitlab if the API support it but since there is no coherence with our marquee provider implementation (github apps) i am not sure if i want it (and as you said that's something the user could do via API calls)

chmouel avatar Mar 28 '24 06:03 chmouel