New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-18272] Added functionality to expose Maven GAV info through envvars #933

Closed
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+27 −2
Diff settings

Always

Just for now

@@ -36,15 +36,18 @@
import hudson.maven.reporters.MavenAggregatedArtifactRecord;
import hudson.maven.reporters.MavenFingerprinter;
import hudson.maven.reporters.MavenMailer;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.Cause.UpstreamCause;
import hudson.model.Computer;
import hudson.model.Environment;
import hudson.model.EnvironmentContributingAction;
import hudson.model.Executor;
import hudson.model.Fingerprint;
import hudson.model.InvisibleAction;
import hudson.model.Node;
import hudson.model.ParameterDefinition;
import hudson.model.ParametersAction;
@@ -72,6 +75,7 @@
import java.net.URLClassLoader;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -984,6 +988,27 @@ private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVa
needsDependencyGraphRecalculation = true;
}
modules.putAll(old);
// Put GAV IDs etc as EnvVars (JENKINS-18272)
final Collection<String> newEnvVars = new ArrayList<String>(

This comment has been minimized.

@demobox

demobox Sep 13, 2013

I'm guessing we explicitly want to make a copy of the list here...

Arrays.asList(
"POM_DISPLAYNAME=" + poms.get(0).displayName,
"POM_VERSION=" + poms.get(0).version,
"POM_GROUPID=" + poms.get(0).groupId,
"POM_ARTIFACTID=" + poms.get(0).artifactId,
"POM_PACKAGING=" + poms.get(0).packaging,
"POM_RELATIVEPATH=" + poms.get(0).relativePath
)
);
abstract class PublishEnvVarAction extends InvisibleAction implements EnvironmentContributingAction {}
addAction(new PublishEnvVarAction() {
public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) {
for (String s : newEnvVars) {
env.addLine(s);
}
}
});
}
// we might have added new modules
@@ -101,12 +101,12 @@
/**
* maven groupId
*/
private final String groupId;
public final String groupId;
/**
* maven artifactId
*/
private final String artifactId;
public final String artifactId;
public final Notifier mailNotifier;
ProTip! Use n and p to navigate between commits in a pull request.