Skip to content

Commit

Permalink
JENKINS-41677 Expose display URLs in environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
James Dumay committed Feb 2, 2017
1 parent 3b5e95f commit 8d7efad
Showing 1 changed file with 28 additions and 0 deletions.
@@ -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));
}
}

0 comments on commit 8d7efad

Please sign in to comment.