Skip to content

Commit 037ae6e

Browse files
andreitroiebbcKostyaSha
authored andcommitted
Labels as environment variable (#207)
* Add pull request labels as an environment variable. The contents will be a comma-separated string of all the labels * Add line in documentation to mention the labels environment variable * Style fix
1 parent e15436b commit 037ae6e

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

docs/Configuration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ like `Build #${BUILD_NUMBER} started`
4545
- `GITHUB_PR_STATE` - `OPEN`
4646
- `GITHUB_PR_COMMENT_BODY` - `test foo, bar tags please.` When PR was triggered by comment.
4747
- `GITHUB_PR_COMMENT_BODY_MATCH` - `foo, bar` When PR wass triggered by comment and had group match.
48+
- `GITHUB_PR_LABELS` - `label1,label2` Comma-separated list of labels that the PR has. Empty if the PR has no labels.
4849

4950
=== Branch Trigger
5051

github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/data/GitHubPREnv.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public enum GitHubPREnv {
2929
NUMBER,
3030
STATE,
3131
COMMENT_BODY,
32-
COMMENT_BODY_MATCH;
32+
COMMENT_BODY_MATCH,
33+
LABELS;
3334

3435
public static final String PREFIX = "GITHUB_PR_";
3536

github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/trigger/JobRunnerForCause.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.COND_REF;
5353
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.BODY;
5454
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.HEAD_SHA;
55+
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.LABELS;
5556
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.NUMBER;
5657
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.SHORT_DESC;
5758
import static org.jenkinsci.plugins.github.pullrequest.data.GitHubPREnv.SOURCE_BRANCH;
@@ -289,7 +290,8 @@ public QueueTaskFuture<?> startJob(GitHubPRCause cause, Cause additionalCause) {
289290
NUMBER.param(String.valueOf(cause.getNumber())),
290291
STATE.param(String.valueOf(cause.getState())),
291292
COMMENT_BODY.param(String.valueOf(cause.getCommentBody())),
292-
COMMENT_BODY_MATCH.param(String.valueOf(cause.getCommentBodyMatch()))
293+
COMMENT_BODY_MATCH.param(String.valueOf(cause.getCommentBodyMatch())),
294+
LABELS.param(String.join(",", cause.getLabels()))
293295
);
294296
parameters.addAll(pluginParameters);
295297

0 commit comments

Comments
 (0)