Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1178ed2
swapping order of param substitution when getting effective client na…
stuartrowe May 3, 2014
bbfd091
Added the jsr305 dependency
oleg-nenashev May 22, 2014
a5ad0d5
Moved the variables substitution logic to MacroStringHelper
oleg-nenashev May 22, 2014
d6e566a
Handle node environment variables in getDefaultSubstitutions(Node)
oleg-nenashev May 22, 2014
7b3f3dd
Added Coverity folder to .gitignore
oleg-nenashev May 22, 2014
2993d21
Made MacroStringHelper as generic as possible.
oleg-nenashev May 23, 2014
7247643
Added PerforceSCM instance parameter to new MacroStringHelper methods
oleg-nenashev May 23, 2014
f2dedc2
Aggressive substitution error checks in PerforceSCM.
oleg-nenashev May 23, 2014
60ef6c4
Added PerforceSCM retrieval method to PerforceTagAction
oleg-nenashev May 23, 2014
00a1b88
Fix missing substitutions in PerforceSCM and PerforceTagNotifier.
oleg-nenashev May 23, 2014
9e1b628
Refactoring of MacroStringHelper: annotations, proper variables subst…
oleg-nenashev May 24, 2014
7747c77
Minor refactoring of PerforceSCM class
oleg-nenashev May 24, 2014
8effc7f
Generalized the substitution of ${nodename}, ${hostname} and ${hash}
oleg-nenashev May 31, 2014
2f821d6
Code Annotations
oleg-nenashev May 31, 2014
c5ccf6f
Merge remote-tracking branch 'remotes/stuartrowe/master' into variabl…
oleg-nenashev Jun 2, 2014
93a7535
Document compatibility aspects of getDefaultSubstitutions()
oleg-nenashev Jun 16, 2014
bdaca59
Add support of default core substitution variables and the computer e…
oleg-nenashev Jun 16, 2014
50a9daf
MacroStringHelper methods are interruptable
oleg-nenashev Jun 16, 2014
f62db63
Inject EXECUTOR_NUMBER=UNKNOWNEXECUTOR if the executor is not available.
oleg-nenashev Jun 17, 2014
a6ecf27
Do not substitute EXECUTOR_NUMBER variables.
oleg-nenashev Jun 17, 2014
bd0d0cf
Explicitly forbid the EXECUTOR_NUMBER field
oleg-nenashev Jun 21, 2014
a35f1fe
[FIXED JENKINS-23599] - Substitute Matrix Axis values in PerforceSCM
oleg-nenashev Jun 27, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ work
.classpath
.settings
.project
.DS_Store
.DS_Store

# Coverity
/cov-int
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
<type>jar</type>
</dependency>
</dependencies>

<distributionManagement>
<repository>
Expand Down
39 changes: 8 additions & 31 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import hudson.Extension;
import hudson.FilePath;
import hudson.Util;
import hudson.FilePath.FileCallable;
import hudson.Launcher;
import static hudson.Util.fixNull;
import hudson.matrix.MatrixBuild;
Expand All @@ -28,15 +27,13 @@
import hudson.plugins.perforce.config.WorkspaceCleanupConfig;
import hudson.plugins.perforce.utils.MacroStringHelper;
import hudson.plugins.perforce.utils.ParameterSubstitutionException;
import hudson.remoting.VirtualChannel;
import hudson.scm.ChangeLogParser;
import hudson.scm.PollingResult;
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import hudson.scm.SCMRevisionState;
import hudson.slaves.EnvironmentVariablesNodeProperty;
import hudson.slaves.NodeProperty;
import hudson.tasks.BuildTrigger;
import hudson.tasks.Messages;
import hudson.util.FormValidation;
import hudson.util.LogTaskListener;
Expand All @@ -56,7 +53,6 @@
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.net.InetAddress;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
Expand Down Expand Up @@ -458,7 +454,7 @@ protected Depot getDepot(Launcher launcher, FilePath workspace, AbstractProject

Depot depot = new Depot(p4Factory);

if (build != null) {
if (build != null) { // We can retrieve all parameters from the build's environment
depot.setClient(MacroStringHelper.substituteParameters(p4Client, build, null));
depot.setUser(MacroStringHelper.substituteParameters(p4User, build, null));
depot.setPort(MacroStringHelper.substituteParameters(p4Port, build, null));
Expand Down Expand Up @@ -514,6 +510,13 @@ protected Depot getDepot(Launcher launcher, FilePath workspace, AbstractProject
return depot;
}

/**
* @deprecated
* Use {@link MacroStringHelper#getDefaultSubstitutions(hudson.model.AbstractProject, java.lang.String)}
*/
public Hashtable<String, String> getDefaultSubstitutions(AbstractProject project) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a temporary solution to compile the code. I'll remove it and explicitly use MacroStringHelper.
The previous method was implementation private, hence there won't be any issues

return MacroStringHelper.getDefaultSubstitutions(project, p4User);
}

/**
* Override of SCM.buildEnvVars() in order to setup the last change we have
Expand Down Expand Up @@ -658,31 +661,6 @@ public Object readResolve() {
return this;
}

private Hashtable<String, String> getDefaultSubstitutions(AbstractProject project) {
Hashtable<String, String> subst = new Hashtable<String, String>();
subst.put("JOB_NAME", MacroStringHelper.getSafeJobName(project));
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
subst.putAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars());
}
}
ParametersDefinitionProperty pdp = (ParametersDefinitionProperty) project.getProperty(hudson.model.ParametersDefinitionProperty.class);
if (pdp != null) {
for (ParameterDefinition pd : pdp.getParameterDefinitions()) {
try {
ParameterValue defaultValue = pd.getDefaultParameterValue();
if (defaultValue != null) {
String name = defaultValue.getName();
String value = defaultValue.createVariableResolver(null).resolve(name);
subst.put(name, value);
}
} catch (Exception e) {
}
}
}
subst.put("P4USER", MacroStringHelper.substituteParametersNoCheck(p4User, subst));
return subst;
}

private String getEffectiveProjectPath(AbstractBuild build, AbstractProject project, PrintStream log, Depot depot)
throws PerforceException, ParameterSubstitutionException {
Expand Down Expand Up @@ -1291,7 +1269,6 @@ protected PollingResult compareRemoteRevisionWith(AbstractProject<?, ?> project,
return PollingResult.BUILD_NOW;
}

Hashtable<String, String> subst = getDefaultSubstitutions(project);
try {
Node buildNode = getPollingNode(project);
Depot depot;
Expand Down
Loading