Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acceptGitlabMR doesn`t throw exception in case of merge failure #1591

Open
Nataliia-Kyr opened this issue Nov 6, 2023 · 1 comment
Open
Labels
bug For changelog: Minor bug. Will be listed after features

Comments

@Nataliia-Kyr
Copy link

Nataliia-Kyr commented Nov 6, 2023

Jenkins and plugins versions report

Environment
Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

Gitlab plugin version: 1.5.33
Gitlab version: 15.11.13
Jenkins version: 2.401.1 (running as a Docker container on Red Hat Enterprise Linux v8.8 Ootpa)
Job type: Pipeline

Reproduction steps

  1. Set a GitLab connection in Jenkins with GitLab plugin, using API token
  2. Set a Webhook in GitLab to Jenkins job (200 status is shown when event is pushed)
  3. Create MR and make it unmergeable (for example, need a rebase on destination branch)
  4. Get GitLab MR info with the Webhook event and try to accept it using acceptGitLabMR
    Source code (Groovy):
properties([
  gitLabConnection('project_gitlab'),
  pipelineTriggers([
      [
        $class: 'GitLabPushTrigger',
        triggerOnPush: true,
        triggerOnMergeRequest: true,
        ciSkip: false,
        setBuildDescription: true,
        addNoteOnMergeRequest: true,
        addCiMessage: true,
        addVoteOnMergeRequest: true,
        acceptMergeRequestOnSuccess:  true
        ...
      ]
  ])
])

...some build steps...

acceptGitLabMR(useMRDescription: true, removeSourceBranch: true)
  1. Get result "Success" and following message in Console logs "Failed to accept merge request for project '24': HTTP 422 Unprocessable Entity".
    Also, if command is assigned to variable, it`s value is always "null". Example:

acceptGitLabMR = acceptGitLabMR(useMRDescription: true, removeSourceBranch: true)

Expected Results

acceptGitlabMR throws Exception if for some reason merging MR has failed. For example, if MR needs a rebase and GitLab configured to not allow auto-merging such MRs

Actual Results

acceptGitlabMR always returns "Success" even if MR is not actually merged. Currently it`s not possible to validate if MR was successfully merged or not

Anything else?

Result of command acceptGitlabMR() needs to be handled and validated. For example, to be able to use it in try-catch section.

@Nataliia-Kyr Nataliia-Kyr added the bug For changelog: Minor bug. Will be listed after features label Nov 6, 2023
@AniketNS
Copy link
Contributor

AniketNS commented Jan 5, 2024

Hey maintainers, I was trying to solve this issue and wanted to ask you some questions about it.

To solve this issue do we have to make changes in the core plugin like below?

Draft code to check whether the merge request is successful or not.
Screenshot from 2024-01-05 12-38-08

or we should simply make the changes in the pipeline script

README.md modification like the below
Screenshot from 2024-01-05 12-43-25

Can anyone please help me with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Minor bug. Will be listed after features
Projects
None yet
Development

No branches or pull requests

2 participants