gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

Add gitlab project id to defined variable

Open mikhatanu opened this issue 1 year ago • 3 comments

What feature do you want to see added?

Gitlab webhook sends post request that contains "project_id". Currently, this is not mapped to a defined variable. This can be useful when repository are trying to call gitlab's api, for example when uploading generic package.

Upstream changes

No response

Are you interested in contributing this feature?

No response

mikhatanu avatar Sep 11 '24 04:09 mikhatanu

@mikhatanu , I am interested to solve it. Can you assign me this issue?

Aditya-PS-05 avatar Nov 07 '24 05:11 Aditya-PS-05

Hi @Aditya-PS-05 we do not assign issues but you are welcome to work on this via a PR

krisstern avatar Nov 07 '24 05:11 krisstern

@krisstern I have a problem while trying to solve this. There are originally 2 attributes inside CauseData about this, sourceProjectId and targetProjectId. There are at least 5 WebHookTriggerHandlers according to the code I read that will assign them, each with its own behavior:

  1. PushHookTriggerHandlerImpl assigns both with the project_id attribute of the hook directly as mentioned in this issue.
  2. PipelineHookTriggerHandlerImpl assigns both with the project.id attribute of the hook.
  3. MergeRequestHookTriggerHandlerImpl assign sourceProjectId with the objectAttributes.sourceProjectId attribute of the hook and targetProjectId with the objectAttributes.sourceProjectId attribute of the hook.
  4. NoteHookTriggerHandlerImpl assign sourceProjectId with the mergeRequest.sourceProjectId attribute of the hook and targetProjectId with the mergeRequest.targetProjectId attribute of the hook.
  5. OpenMergeRequestPushHookTriggerHandler assign sourceProjectId with the project ID of the opened MR and targetProjectId with the "project_id" attribute of the hook.

I believe that CauseData can use one of sourceProjectId and targetProjectId as its value directly without having to change any other logic. The problem is, which one should it be? Otherwise, another projectId attribute in the CauseData can be created, but that doesn't solve the problem because it's still uncertain what value should be given since not eveny WebHook extension has a projectId attribute to be required.

dodo920306 avatar Apr 18 '25 06:04 dodo920306