diff --git a/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java b/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java index 9e06420e8..a26d20534 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java @@ -58,6 +58,7 @@ public final class CauseData { private final String createdAt; private final String finishedAt; private final String buildDuration; + private final List labels; @GeneratePojoBuilder(withFactoryMethod = "*") CauseData(ActionType actionType, Integer sourceProjectId, Integer targetProjectId, String branch, String sourceBranch, String userName, @@ -66,7 +67,7 @@ public final class CauseData { Integer mergeRequestIid, Integer mergeRequestTargetProjectId, String targetBranch, String targetRepoName, String targetNamespace, String targetRepoSshUrl, String targetRepoHttpUrl, String triggeredByUser, String before, String after, String lastCommit, String targetProjectUrl, String triggerPhrase, String mergeRequestState, String mergedByUser, String mergeRequestAssignee, String ref, String isTag, - String sha, String beforeSha, String status, String stages, String createdAt, String finishedAt, String buildDuration) { + String sha, String beforeSha, String status, String stages, String createdAt, String finishedAt, String buildDuration, List labels) { this.actionType = checkNotNull(actionType, "actionType must not be null."); this.sourceProjectId = checkNotNull(sourceProjectId, "sourceProjectId must not be null."); this.targetProjectId = checkNotNull(targetProjectId, "targetProjectId must not be null."); @@ -108,6 +109,7 @@ public final class CauseData { this.createdAt = createdAt; this.finishedAt = finishedAt; this.buildDuration = buildDuration; + this.labels = labels; } public Map getBuildVariables() { @@ -149,6 +151,7 @@ public Map getBuildVariables() { variables.put("finishedAt", finishedAt); variables.put("duration", buildDuration); variables.putIfNotNull("gitlabTriggerPhrase", triggerPhrase); + if (labels != null) variables.put("gitlabLabels", StringUtils.join(labels,' ')); return variables; } diff --git a/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/merge/MergeRequestHookTriggerHandlerImpl.java b/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/merge/MergeRequestHookTriggerHandlerImpl.java index 40dcd1964..62cd80d90 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/merge/MergeRequestHookTriggerHandlerImpl.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/merge/MergeRequestHookTriggerHandlerImpl.java @@ -135,6 +135,7 @@ protected CauseData retrieveCauseData(MergeRequestHook hook) { .withTriggeredByUser(hook.getObjectAttributes().getLastCommit().getAuthor().getName()) .withLastCommit(hook.getObjectAttributes().getLastCommit().getId()) .withTargetProjectUrl(hook.getObjectAttributes().getTarget().getWebUrl()) + .withLabels(hook.getObjectAttributes().getLabels()) .build(); } diff --git a/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java b/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java index ca36879a7..5edeb9012 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java @@ -84,6 +84,7 @@ protected CauseData retrieveCauseData(NoteHook hook) { .withLastCommit(hook.getMergeRequest().getLastCommit().getId()) .withTargetProjectUrl(hook.getMergeRequest().getTarget().getWebUrl()) .withTriggerPhrase(hook.getObjectAttributes().getNote()) + .withLabels(hook.getMergeRequest().getLabels()) .build(); }