/** * Adds environmental variables for the builds to the given map. * * <p> * This can be used to propagate information from SCM to builds * (for example, SVN revision number.) * * <p> * This method is invoked whenever someone does {@link AbstractBuild#getEnvironment(TaskListener)}, via * {@link #buildEnvVars(AbstractBuild, Map)}, which can be before/after your checkout method is invoked. So if you * are going to provide information about check out (like SVN revision number that was checked out), be prepared * for the possibility that the check out hasn't happened yet. * * @since 2.60 */ public void buildEnvironment(@Nonnull Run<?,?> build, @Nonnull Map<String,String> env) { if (build instanceof AbstractBuild) { buildEnvVars((AbstractBuild)build, env); } }
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
public void superBuildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { super.buildEnvVars(build, env); }
/** * Adds environmental variables for the builds to the given map. * * <p> * This can be used to propagate information from SCM to builds * (for example, SVN revision number.) * * <p> * This method is invoked whenever someone does {@link AbstractBuild#getEnvironment(TaskListener)}, via * {@link #buildEnvVars(AbstractBuild, Map)}, which can be before/after your checkout method is invoked. So if you * are going to provide information about check out (like SVN revision number that was checked out), be prepared * for the possibility that the check out hasn't happened yet. * * @since 2.60 */ public void buildEnvironment(@Nonnull Run<?,?> build, @Nonnull Map<String,String> env) { if (build instanceof AbstractBuild) { buildEnvVars((AbstractBuild)build, env); } }
@Override public void buildEnvVars(AbstractBuild<?,?> build, Map<String, String> env) { // Add each SCM's env vars, appending indices where needed to avoid collisions for (int i = 0; i < scms.size(); i++) { try { EnvVars currScmVars = new EnvVars(); scms.get(i).buildEnvVars(build, currScmVars); for (Entry<String, String> entry : currScmVars.entrySet()) { if (env.containsKey(entry.getKey())) { // We have a collision; append the index of this SCM to the env var name env.put(entry.getKey() + "_" + i, entry.getValue()); } else { // No collision; just put the var as usual env.put(entry.getKey(), entry.getValue()); } } } catch(NullPointerException npe) {} } }
/** * Sets the <tt>SVN_REVISION</tt> environment variable during the build. */ @Override public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { super.buildEnvVars(build, env); ModuleLocation[] svnLocations = getLocations(build); try { Map<String, Long> revisions = parseRevisionFile(build); if (svnLocations.length == 1) { Long rev = revisions.get(svnLocations[0].remote); if (rev != null) { env.put("SVN_REVISION", rev.toString()); env.put("SVN_URL", svnLocations[0].getURL()); } } else if (svnLocations.length > 1) { for (int i = 0; i < svnLocations.length; i++) { Long rev = revisions.get(svnLocations[i].remote); if (rev != null) { env.put("SVN_REVISION_" + (i + 1), rev.toString()); env.put("SVN_URL_" + (i + 1), svnLocations[i].getURL()); } } } } catch (IOException e) { // ignore this error LOGGER.log(Level.FINEST, "Exception while building envVars. Error will be ignored.", e); } }
/** * Sets the <tt>SVN_REVISION</tt> environment variable during the build. */ @Override public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { super.buildEnvVars(build, env); ModuleLocation[] svnLocations = getLocations(build); try { Map<String, Long> revisions = parseRevisionFile(build); if (svnLocations.length == 1) { Long rev = revisions.get(svnLocations[0].remote); if (rev != null) { env.put("SVN_REVISION", rev.toString()); env.put("SVN_URL", svnLocations[0].getURL()); } } else if (svnLocations.length > 1) { for (int i = 0; i < svnLocations.length; i++) { Long rev = revisions.get(svnLocations[i].remote); if (rev != null) { env.put("SVN_REVISION_" + (i + 1), rev.toString()); env.put("SVN_URL_" + (i + 1), svnLocations[i].getURL()); } } } } catch (IOException e) { // ignore this error LOGGER.log(Level.FINEST, "Exception while building envVars. Error will be ignored.", e); } }
@Override public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { initPython(); if (pexec.isImplemented(8)) { pexec.execPythonVoid("build_env_vars", build, env); } else { super.buildEnvVars(build, env); } }
public void buildEnvVars(AbstractBuild<?, ?> build, java.util.Map<String, String> env) { super.buildEnvVars(build, env); String branch = getSingleBranch(build); if (branch != null) { env.put(GIT_BRANCH, branch); } BuildData bd = fixNull(getBuildData(build, false)); if (bd != null && bd.getLastBuiltRevision() != null) { String commit = bd.getLastBuiltRevision().getSha1String(); if (commit != null) { env.put(GIT_COMMIT, commit); } } }
super.buildEnvVars(build, env); env.put("P4PORT", p4Port); env.put("P4USER", p4User);
public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { super.buildEnvVars(build, env); GitUtils.buildBranchEnvVar(build, env, getRepositories(), getBranches()); BuildData bd = fixNull(getBuildData(build, false)); if (bd != null && bd.getLastBuiltRevision() != null) { String commit = bd.getLastBuiltRevision().getSha1String(); if (commit != null) { env.put(GIT_COMMIT, commit); } } }
e.put("PROMOTED_USER_ID", getUserId()); EnvVars envScm = new EnvVars(); target.getProject().getScm().buildEnvVars( target, envScm ); for ( Entry<String, String> entry : envScm.entrySet() )
scm.buildEnvVars(build, variables);
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
p.getScm().buildEnvVars(b, env);
p.getScm().buildEnvVars(b, env);
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); // servlet container may have set CLASSPATH in its launch script, // so don't let that inherit to the new child process. // see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html env.put("CLASSPATH",""); JDK jdk = project.getJDK(); if (jdk != null) { Computer computer = Computer.currentComputer(); if (computer != null) { // just in case were not in a build jdk = jdk.forNode(computer.getNode(), log); } jdk.buildEnvVars(env); } project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); // servlet container may have set CLASSPATH in its launch script, // so don't let that inherit to the new child process. // see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html env.put("CLASSPATH",""); JDK jdk = project.getJDK(); if (jdk != null) { Computer computer = Computer.currentComputer(); if (computer != null) { // just in case were not in a build jdk = jdk.forNode(computer.getNode(), log); } jdk.buildEnvVars(env); } project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); // servlet container may have set CLASSPATH in its launch script, // so don't let that inherit to the new child process. // see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html env.put("CLASSPATH",""); JDK jdk = project.getJDK(); if (jdk != null) { Computer computer = Computer.currentComputer(); if (computer != null) { // just in case were not in a build jdk = jdk.forNode(computer.getNode(), log); } jdk.buildEnvVars(env); } project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
project.getScm().buildEnvVars(this, env);