-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathGitLabEnvironmentContributor.java
More file actions
40 lines (36 loc) · 1.84 KB
/
GitLabEnvironmentContributor.java
File metadata and controls
40 lines (36 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.jenkinsci.plugins.gitlab;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import hudson.EnvVars;
import hudson.Extension;
import hudson.model.EnvironmentContributor;
import hudson.model.Run;
import hudson.model.TaskListener;
@Extension
public class GitLabEnvironmentContributor extends EnvironmentContributor {
@Override
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs,
@Nonnull TaskListener listener) throws IOException, InterruptedException {
GitlabCause cause = (GitlabCause) r.getCause(GitlabCause.class);
if (cause != null) {
Map<String, String> variables = new HashMap<>();
variables.put("gitlabMergeRequestId", cause.getMergeRequestId() + "");
variables.put("gitlabMergeRequestIid", cause.getMergeRequestIid() + "");
variables.put("gitlabMergeRequestState", cause.getMergeRequestState() + "");
variables.put("gitlabMergeRequestAuthorEmail", cause.getAuthorEmail());
variables.put("gitlabMergeRequestAssigneeEmail", cause.getAssigneeEmail());
variables.put("gitlabSourceName", cause.getSourceName());
variables.put("gitlabSourceRepository", cause.getSourceRepository());
variables.put("gitlabSourceBranch", cause.getSourceBranch());
variables.put("gitlabTargetBranch", cause.getTargetBranch());
variables.put("gitlabTitle", cause.getTitle());
variables.put("gitlabDescription", cause.getDescription());
variables.put("gitlabSourceProjectId", cause.getSourceProjectId()+"");
variables.put("gitlabTargetProjectId", cause.getTargetProjectId()+"");
variables.put("gitlabLastCommitId", cause.getLastCommitId());
envs.overrideAll(variables);
}
}
}