package org.jenkinsci.plugins.p4.workspace; import hudson.slaves.EnvironmentVariablesNodeProperty; import hudson.slaves.NodeProperty; import hudson.slaves.NodePropertyDescriptor; import hudson.util.DescribableList; import jenkins.model.Jenkins; import org.jenkinsci.plugins.p4.review.ReviewProp; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.logging.Logger; public class Expand implements Serializable { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(Expand.class.getName()); private Map<String, String> formatTags = new HashMap<String, String>(); public Expand(Map<String, String> map) { Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { logger.warning("Jenkins instance is null!"); return; } DescribableList<NodeProperty<?>, NodePropertyDescriptor> props = jenkins.getGlobalNodeProperties(); if (props != null) { for (NodeProperty<?> node : props) { if (node instanceof EnvironmentVariablesNodeProperty) { EnvironmentVariablesNodeProperty env = (EnvironmentVariablesNodeProperty) node; formatTags.putAll((env).getEnvVars()); } } } for (Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (ReviewProp.isProp(key)) { // Known Perforce Review property; prefix with namespace key = ReviewProp.NAMESPACE + key; } set(key, value); } } public String format(String format, boolean wildcard) { if (formatTags != null) { for (Entry<String, String> entry : formatTags.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (value != null) { format = format.replace("${" + key + "}", value); } } } // cleanup undefined tags if (wildcard) { format = format.replaceAll("\\$\\{.+?\\}", "*"); } format = format.replace("${", ""); format = format.replace("}", ""); return format; } public String formatID(String format) { if (formatTags != null) { for (Entry<String, String> entry : formatTags.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if("NODE_NAME".equals(key)) { continue; } if("EXECUTOR_NUMBER".equals(key)) { continue; } if("BUILD_NUMBER".equals(key)) { continue; } if (value != null) { format = format.replace("${" + key + "}", value); } } } format = format.replace("${", ""); format = format.replace("}", ""); return format; } public String clean(String id) { id = id.replaceAll(" ", "_"); id = id.replaceAll(",", "-"); id = id.replaceAll("=", "-"); id = id.replaceAll("/", "-"); return id; } public void set(String tag, String value) { formatTags.put(tag, value); } public String get(String tag) { if (formatTags == null) { return null; } return formatTags.get(tag); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 27675 | Paul Allen |
Substitute missing Axes for Key Name. Added useKey option to substitute empty keys in client views, depot paths and stream paths. JENKINS-55985 |
||
#9 | 25001 | Paul Allen |
Strip undefined variables. JENKINS-53723 |
||
#8 | 24942 | Paul Allen |
Deep clone of Workspace objects. WorkspaceSpec was not cloned and caused the View to change. JENKINS-54695 |
||
#7 | 24488 | Paul Allen |
Min version Jenkins 2.60.3 Upgrade dependencies and move to Java 8. |
||
#6 | 21372 | Paul Allen |
Support custom SyncID. Exclude BUILD_NUMBER from SyncID. Pushed logging to higher level, so it is not reporting TagActions when building the Environment. JENKINS-40460 |
||
#5 | 21324 | Paul Allen |
Create syncID to track syncs when polling. Original design used the client name to track the sync from previous builds, however as polling is on the master if NODE_NAME is used it breaks with slaves. JENKINS-40356 |
||
#4 | 20308 | Paul Allen |
P4Groovy (experimental) Get a P4 object in groovy. Supporting basic functions: ’run’ (to run perforce commands), ‘fetch’ and ‘save’ (to access Perforce specs). |
||
#3 | 19593 | Paul Allen | More minor fixes to satisfy FindBugs Analysis. | ||
#2 | 19581 | Paul Allen | Minor fixes to satisfy FindBugs Analysis. | ||
#1 | 13681 | Paul Allen |
Abstracted Expand class from Workspace. Added support for Label variable expansion in the name and description. |