Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-41677 Expose display URLs in environment variables
- Loading branch information
James Dumay
committed
Feb 2, 2017
1 parent
3b5e95f
commit 8d7efad
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/org/jenkinsci/plugins/displayurlapi/EnvironmentContributorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.jenkinsci.plugins.displayurlapi; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.EnvironmentContributor; | ||
import hudson.model.Job; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.IOException; | ||
|
||
@Extension | ||
public class EnvironmentContributorImpl extends EnvironmentContributor { | ||
@Override | ||
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException { | ||
super.buildEnvironmentFor(r, envs, listener); | ||
envs.put("RUN_DISPLAY_URL", DisplayURLProvider.get().getRunURL(r)); | ||
envs.put("RUN_CHANGES_DISPLAY_URL", DisplayURLProvider.get().getChangesURL(r)); | ||
|
||
} | ||
|
||
@Override | ||
public void buildEnvironmentFor(@Nonnull Job j, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException { | ||
super.buildEnvironmentFor(j, envs, listener); | ||
envs.put("JOB_DISPLAY_URL", DisplayURLProvider.get().getJobURL(j)); | ||
} | ||
} |