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

MergeRequest class is not working

Open raphaelbadia opened this issue 3 years ago • 0 comments

Context

  • Gitlab plugin version: X.Y.Z
  • Gitlab version: 11.7.4
  • Jenkins version: 2.204.1
  • Job type: Pipeline

Logs & Traces

Please include any relevant log that could serve to better understand the source of your issue For Jenkins Gitlab Plugin logs, follow instruction in User Support section. For Gitlab logs, ask an administrator to provide you the relevant Gitlab logs.

Problem description

In a pipeline groovy script we use createMergeRequest to automatically create merge requests to a branch.

I saw here that createMergeRequest returns a MergeRequest class, which has the methods setLabels and setAssignee.

We have a pipeline that creates a new merge request back to develop every time a hotfix is pushed to master :

My grrovy script looks like:

#!groovy
import static com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient;

def createMergeBackMR() {
   // ....
    def mr = gitLabClient.createMergeRequest(projectId, targetBranch, newMRTarget, "Merge back $targetBranch -> $newMRTarget");
    mr.setLabels(["PAT", "MERGE BACK"]);
    // mr.setAssignee("rbadia") // needs a User but don't know how to instanciate it
}

node {
    createMergeBackMR();
}

The merge request is created successfully, but no labels are set. Did I miss something ?

Sorry if the question is stupid, I don't do java / groovy / devops at all usually. I have no idea on how this works...

Thanks !

raphaelbadia avatar Jan 19 '21 08:01 raphaelbadia