Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.kestra.plugin.gitlab;
package io.kestra.plugin.gitlab.mergerequests;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.kestra.core.http.HttpRequest;
Expand All @@ -9,6 +9,7 @@
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.RunnableTask;
import io.kestra.core.runners.RunContext;
import io.kestra.plugin.gitlab.AbstractGitLabTask;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.*;
Expand All @@ -28,28 +29,31 @@
description = "Create a new merge request in a GitLab project. " +
"You need to provide a valid GitLab project ID and a personal access token with the necessary permissions."
)
@Plugin(examples = {
@Example(
title = "Create a merge request in a GitLab project using a project access token.",
full = true,
code = """
id: gitlab_merge_request
namespace: company.team

tasks:
- id: create_merge_request
type: io.kestra.plugin.gitlab.MergeRequest
url: https://gitlab.example.com
token: "{{ secret('GITLAB_TOKEN') }}"
projectId: "123"
title: "Feature: Add new functionality"
mergeRequestDescription: "This merge request adds new functionality to the project"
sourceBranch: "feat-testing"
targetBranch: "main"
"""
)
})
public class MergeRequest extends AbstractGitLabTask implements RunnableTask<MergeRequest.Output> {
@Plugin(
examples = {
@Example(
title = "Create a merge request in a GitLab project using a project access token.",
full = true,
code = """
id: gitlab_merge_request
namespace: company.team

tasks:
- id: create_merge_request
type: io.kestra.plugin.gitlab.mergerequests.Create
url: https://gitlab.example.com
token: "{{ secret('GITLAB_TOKEN') }}"
projectId: "123"
title: "Feature: Add new functionality"
mergeRequestDescription: "This merge request adds new functionality to the project"
sourceBranch: "feat-testing"
targetBranch: "main"
"""
)
},
aliases = "io.kestra.plugin.gitlab.MergeRequest"
)
public class Create extends AbstractGitLabTask implements RunnableTask<Create.Output> {

@Schema(title = "Merge request title")
@NotNull
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/icons/io.kestra.plugin.gitlab.mergerequests.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/main/resources/metadata/mergerequests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
group: io.kestra.plugin.gitlab.mergerequests
name: "mergerequests"
title: "Merge Requests"
description: "Tasks that create, update, and fetch GitLab Merge Requests."
body: "Set the GitLab host, project ID, and access token to handle Merge Requests."
videos: []
createdBy: "Kestra Core Team"
managedBy: "Kestra Core Team"
2 changes: 1 addition & 1 deletion src/test/java/io/kestra/plugin/gitlab/WireMockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@KestraTest
public abstract class WireMockTest {
@RegisterExtension
static WireMockExtension wireMock = WireMockExtension.newInstance()
public static WireMockExtension wireMock = WireMockExtension.newInstance()
.options(wireMockConfig().dynamicPort())
.build();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.kestra.plugin.gitlab;
package io.kestra.plugin.gitlab.issues;

import io.kestra.core.models.property.Property;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.plugin.gitlab.issues.Create;
import io.kestra.plugin.gitlab.WireMockTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

Expand All @@ -13,7 +13,7 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class CreateIssueTest extends WireMockTest {
public class CreateTest extends WireMockTest {
@Inject
private RunContextFactory runContextFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

package io.kestra.plugin.gitlab;
package io.kestra.plugin.gitlab.issues;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.kestra.core.models.property.Property;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.plugin.gitlab.issues.Search;
import io.kestra.plugin.gitlab.WireMockTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

Expand All @@ -15,7 +15,7 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class SearchIssuesTest extends WireMockTest {
public class SearchTest extends WireMockTest {
@Inject
private RunContextFactory runContextFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.kestra.plugin.gitlab;
package io.kestra.plugin.gitlab.mergerequests;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.kestra.core.models.property.Property;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.plugin.gitlab.WireMockTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

Expand All @@ -13,7 +14,7 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class MergeRequestTest extends WireMockTest {
public class CreateTest extends WireMockTest {
@Inject
private RunContextFactory runContextFactory;

Expand All @@ -30,7 +31,7 @@ void testCreateMergeRequest() throws Exception {

RunContext runContext = runContextFactory.of();

MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.projectId(Property.ofValue("12345"))
.token(Property.ofValue("test-token"))
Expand All @@ -41,7 +42,7 @@ void testCreateMergeRequest() throws Exception {
.targetBranch(Property.ofValue("main"))
.build();

MergeRequest.Output runOutput = task.run(runContext);
Create.Output runOutput = task.run(runContext);

assertThat(runOutput.getMergeReqID(), is(notNullValue()));
assertThat(runOutput.getWebUrl(), is(notNullValue()));
Expand All @@ -55,7 +56,7 @@ void testCreateMergeRequestNotFound() {

RunContext runContext = runContextFactory.of();

MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.projectId(Property.ofValue("54321"))
.token(Property.ofValue("test-token"))
Expand All @@ -73,7 +74,7 @@ void testCreateMergeRequestNotFound() {
void testCreateMergeRequest_missingProjectId() throws Exception {
RunContext runContext = runContextFactory.of();

MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.token(Property.ofValue("test-token"))
.url(Property.ofValue(wireMock.baseUrl()))
Expand All @@ -89,7 +90,7 @@ void testCreateMergeRequest_missingProjectId() throws Exception {
void testCreateMergeRequest_missingToken() throws Exception {
RunContext runContext = runContextFactory.of();

MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.projectId(Property.ofValue("12345"))
.url(Property.ofValue(wireMock.baseUrl()))
Expand All @@ -110,7 +111,7 @@ void testCreateMergeRequestWithEmptyRequiredFields() throws Exception {
RunContext runContext = runContextFactory.of();

// Test with null title - should create MR but GitLab API will likely fail
MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.projectId(Property.ofValue("12345"))
.token(Property.ofValue("test-token"))
Expand All @@ -136,7 +137,7 @@ void testCreateMergeRequestWithMinimalData() throws Exception {

RunContext runContext = runContextFactory.of();

MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.projectId(Property.ofValue("12345"))
.token(Property.ofValue("test-token"))
Expand All @@ -146,7 +147,7 @@ void testCreateMergeRequestWithMinimalData() throws Exception {
.targetBranch(Property.ofValue("main"))
.build();

MergeRequest.Output runOutput = task.run(runContext);
Create.Output runOutput = task.run(runContext);

assertThat(runOutput.getMergeReqID(), is("2"));
assertThat(runOutput.getWebUrl(), is("https://gitlab.example.com/test/merge_requests/2"));
Expand All @@ -164,7 +165,7 @@ void testCreateMergeRequestBadRequest() {

RunContext runContext = runContextFactory.of();

MergeRequest task = MergeRequest.builder()
Create task = Create.builder()
.id("create-merge-request")
.projectId(Property.ofValue("12345"))
.token(Property.ofValue("test-token"))
Expand Down
Loading