Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
JENKINS-41677 Expose display URLs in environment variables (#8)
- Loading branch information
James William Dumay
committed
Feb 2, 2017
1 parent
3b5e95f
commit 6804a3b
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
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 { | ||
DisplayURLProvider urlProvider = DisplayURLProvider.get(); | ||
envs.put("RUN_DISPLAY_URL", urlProvider.getRunURL(r)); | ||
envs.put("RUN_CHANGES_DISPLAY_URL", urlProvider.getChangesURL(r)); | ||
} | ||
|
||
@Override | ||
public void buildEnvironmentFor(@Nonnull Job j, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException { | ||
envs.put("JOB_DISPLAY_URL", DisplayURLProvider.get().getJobURL(j)); | ||
} | ||
} |
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