/** * Creates an {@link VariableResolver} that aggregates all the parameters. * * <p> * If you are a {@link BuildStep}, most likely you should call {@link AbstractBuild#getBuildVariableResolver()}. */ public VariableResolver<String> createVariableResolver(AbstractBuild<?,?> build) { VariableResolver[] resolvers = new VariableResolver[getParameters().size()+1]; int i=0; for (ParameterValue p : getParameters()) { if (p == null) continue; resolvers[i++] = p.createVariableResolver(build); } resolvers[i] = build.getBuildVariableResolver(); return new VariableResolver.Union<String>(resolvers); }
@Override public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) { if (StringUtils.isEmpty(path)) { return null; } try { EnvVars env = build.getEnvironment(listener); String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver()); targetPath = env.expand(targetPath); if (IOUtils.isAbsolute(targetPath)) { return new FilePath(new File(targetPath)); } else { FilePath mrSettings = build.getModuleRoot().child(targetPath); FilePath wsSettings = build.getWorkspace().child(targetPath); try { if (!wsSettings.exists() && mrSettings.exists()) { wsSettings = mrSettings; } } catch (Exception e) { throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote()); } return wsSettings; } } catch (Exception e) { throw new IllegalStateException("failed to prepare global settings.xml"); } }
@Override public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) { if (StringUtils.isEmpty(path)) { return null; } try { EnvVars env = build.getEnvironment(listener); String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver()); targetPath = env.expand(targetPath); if (IOUtils.isAbsolute(targetPath)) { return new FilePath(new File(targetPath)); } else { FilePath mrSettings = build.getModuleRoot().child(targetPath); FilePath wsSettings = build.getWorkspace().child(targetPath); try { if (!wsSettings.exists() && mrSettings.exists()) { wsSettings = mrSettings; } } catch (Exception e) { throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote()); } return wsSettings; } } catch (Exception e) { throw new IllegalStateException("failed to prepare settings.xml"); } }
@Override public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { VariableResolver<String> vr = build.getBuildVariableResolver();
/** * Creates an {@link VariableResolver} that aggregates all the parameters. * * <p> * If you are a {@link BuildStep}, most likely you should call {@link AbstractBuild#getBuildVariableResolver()}. */ public VariableResolver<String> createVariableResolver(AbstractBuild<?,?> build) { VariableResolver[] resolvers = new VariableResolver[parameters.size()+1]; int i=0; for (ParameterValue p : parameters) resolvers[i++] = p.createVariableResolver(build); resolvers[i] = build.getBuildVariableResolver(); return new VariableResolver.Union<String>(resolvers); }
/** * Creates an {@link VariableResolver} that aggregates all the parameters. * * <p> * If you are a {@link BuildStep}, most likely you should call {@link AbstractBuild#getBuildVariableResolver()}. */ public VariableResolver<String> createVariableResolver(AbstractBuild<?,?> build) { VariableResolver[] resolvers = new VariableResolver[parameters.size()+1]; int i=0; for (ParameterValue p : parameters) resolvers[i++] = p.createVariableResolver(build); resolvers[i] = build.getBuildVariableResolver(); return new VariableResolver.Union<String>(resolvers); }
/** * Creates an {@link VariableResolver} that aggregates all the parameters. * * <p> * If you are a {@link BuildStep}, most likely you should call {@link AbstractBuild#getBuildVariableResolver()}. */ public VariableResolver<String> createVariableResolver(AbstractBuild<?,?> build) { VariableResolver[] resolvers = new VariableResolver[parameters.size()+1]; int i=0; for (ParameterValue p : parameters) resolvers[i++] = p.createVariableResolver(build); resolvers[i] = build.getBuildVariableResolver(); return new VariableResolver.Union<String>(resolvers); }
/** * Creates an {@link VariableResolver} that aggregates all the parameters. * * <p> If you are a {@link BuildStep}, most likely you should call * {@link AbstractBuild#getBuildVariableResolver()}. */ public VariableResolver<String> createVariableResolver(AbstractBuild<?, ?> build) { VariableResolver[] resolvers = new VariableResolver[parameters.size() + 1]; int i = 0; for (ParameterValue p : parameters) { resolvers[i++] = p.createVariableResolver(build); } resolvers[i] = build.getBuildVariableResolver(); return new VariableResolver.Union<String>(resolvers); }
private List<FilePath> getPossibleWrapperLocations(AbstractBuild<?, ?> build, Launcher launcher, EnvVars env, FilePath normalizedRootBuildScriptDir) throws IOException, InterruptedException { FilePath moduleRoot = build.getModuleRoot(); if (wrapperLocation != null && wrapperLocation.trim().length() != 0) { // Override with provided relative path to gradlew String wrapperLocationNormalized = wrapperLocation.trim().replaceAll("[\t\r\n]+", ""); wrapperLocationNormalized = Util.replaceMacro(wrapperLocationNormalized.trim(), env); wrapperLocationNormalized = Util.replaceMacro(wrapperLocationNormalized, build.getBuildVariableResolver()); return ImmutableList.of(new FilePath(moduleRoot, wrapperLocationNormalized)); } else if (buildFile != null && !buildFile.isEmpty()) { // Check if the target project is located not at the root dir char fileSeparator = launcher.isUnix() ? '/' : '\\'; int i = buildFile.lastIndexOf(fileSeparator); if (i > 0) { // Check if there is a wrapper script at the target project's dir. FilePath candidate = new FilePath(normalizedRootBuildScriptDir == null ? moduleRoot : normalizedRootBuildScriptDir, buildFile.substring(0, i)); return ImmutableList.of(candidate, moduleRoot); } } return ImmutableList.of(moduleRoot); }
/** * Creates an {@link VariableResolver} that aggregates all the parameters. * * <p> * If you are a {@link BuildStep}, most likely you should call {@link AbstractBuild#getBuildVariableResolver()}. */ public VariableResolver<String> createVariableResolver(AbstractBuild<?,?> build) { VariableResolver[] resolvers = new VariableResolver[getParameters().size()+1]; int i=0; for (ParameterValue p : getParameters()) { if (p == null) continue; resolvers[i++] = p.createVariableResolver(build); } resolvers[i] = build.getBuildVariableResolver(); return new VariableResolver.Union<String>(resolvers); }
body = Util.replaceMacro(body, build.getBuildVariableResolver());
public NodePlan apply(InstancesToRun instance) { String cloudName = instance.cloudName; String templateName = Util.replaceMacro(instance.getActualTemplateName(), build.getBuildVariableResolver()); Supplier<NodeMetadata> nodeSupplier = JCloudsCloud.getByName(cloudName).getTemplate(templateName); // take the hit here, as opposed to later computeCache.getUnchecked(cloudName); return new NodePlan(cloudName, templateName, instance.count, instance.suspendOrTerminate, nodeSupplier); }
@SuppressWarnings("unchecked") public NodePlan apply(InstancesToRun instance) { JCloudsCloud cloud = JCloudsCloud.getByName(instance.cloudName); String templateName = Util.replaceMacro(instance.getActualTemplateName(), build.getBuildVariableResolver()); JCloudsSlaveTemplate template = cloud.getTemplate(templateName); if (template == null) throw new IllegalArgumentException("No such template " + templateName); return new NodePlan(cloud, template, instance.count, scope); } });
public static String buildVar(final AbstractBuild<?, ?> build, final String toResolve) { if (toResolve == null) return null; if (build == null) // is null when called from config page to test connection return toResolve; VariableResolver<String> vr = build.getBuildVariableResolver(); String resolved = Util.replaceMacro(toResolve, vr); try { EnvVars env = build.getEnvironment(new LogTaskListener(LOG, Level.INFO)); resolved = env.expand(resolved); } catch (Exception e) { //TODO no-op? } return resolved; }
@Override public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { if (build.getResult().equals(Result.SUCCESS) || onFailure) { // expand context path using build env variables String contextPath = expandVariable(build.getBuildVariableResolver(), build.getEnvironment(listener), this.contextPath); for (FilePath warFile : build.getWorkspace().list(this.war)) { for (ContainerAdapter adapter : adapters) if (!adapter.redeploy(warFile, contextPath, build, launcher, listener)) build.setResult(Result.FAILURE); } } return true; }
@Override public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) { if (StringUtils.isEmpty(path)) { return null; } try { EnvVars env = build.getEnvironment(listener); String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver()); targetPath = env.expand(targetPath); if (IOUtils.isAbsolute(targetPath)) { return new FilePath(new File(targetPath)); } else { FilePath mrSettings = build.getModuleRoot().child(targetPath); FilePath wsSettings = build.getWorkspace().child(targetPath); try { if (!wsSettings.exists() && mrSettings.exists()) { wsSettings = mrSettings; } } catch (Exception e) { throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote()); } return wsSettings; } } catch (Exception e) { throw new IllegalStateException("failed to prepare global settings.xml"); } }
@Override public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) { if (StringUtils.isEmpty(path)) { return null; } try { EnvVars env = build.getEnvironment(listener); String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver()); targetPath = env.expand(targetPath); if (IOUtils.isAbsolute(targetPath)) { return new FilePath(new File(targetPath)); } else { FilePath mrSettings = build.getModuleRoot().child(targetPath); FilePath wsSettings = build.getWorkspace().child(targetPath); try { if (!wsSettings.exists() && mrSettings.exists()) { wsSettings = mrSettings; } } catch (Exception e) { throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote()); } return wsSettings; } } catch (Exception e) { throw new IllegalStateException("failed to prepare settings.xml"); } }
String value = build.getBuildVariableResolver().resolve(getEnvVar()); if ("true".equalsIgnoreCase(value)) { return Messages.Skipping_Sonar_analysis();
@Override public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { VariableResolver<String> vr = build.getBuildVariableResolver();
VariableResolver<String> buildVariableResolver = ((AbstractBuild<?, ?>) build).getBuildVariableResolver(); singleVersionSpec = buildVariableResolver.resolve(VERSION_SPEC);