/** * Runs before the {@link Builder} runs (but after the checkout has occurred), and performs a set up. * * @param build * The build in progress for which an {@link Environment} object is created. * Never null. * @param launcher * This launcher can be used to launch processes for this build. * If the build runs remotely, launcher will also run a job on that remote machine. * Never null. * @param listener * Can be used to send any message. * @return * non-null if the build can continue, null if there was an error * and the build needs to be aborted. * @throws IOException * terminates the build abnormally. Hudson will handle the exception * and reports a nice error message. * @since 1.150 */ public Environment setUp( AbstractBuild build, Launcher launcher, BuildListener listener ) throws IOException, InterruptedException { if (build instanceof Build) return setUp((Build)build,launcher,listener); else throw new AssertionError("The plugin '" + this.getClass().getName() + "' still uses " + "deprecated setUp(Build,Launcher,BuildListener) method. " + "Update the plugin to use setUp(AbstractBuild, Launcher, BuildListener) instead."); }
r.addAll(step.getProjectActions(this)); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error loading build wrapper.", e);
private StreamBuildListener createBuildListener(@Nonnull RunExecution job, OutputStream logger, Charset charset) throws IOException, InterruptedException { RunT build = job.getBuild(); // Global log filters for (ConsoleLogFilter filter : ConsoleLogFilter.all()) { logger = filter.decorateLogger(build, logger); } // Project specific log filters if (project instanceof BuildableItemWithBuildWrappers && build instanceof AbstractBuild) { BuildableItemWithBuildWrappers biwbw = (BuildableItemWithBuildWrappers) project; for (BuildWrapper bw : biwbw.getBuildWrappersList()) { logger = bw.decorateLogger((AbstractBuild) build, logger); } } return new StreamBuildListener(logger,charset); }
BuildableItemWithBuildWrappers biwbw = (BuildableItemWithBuildWrappers) rootProject; for (BuildWrapper bw : biwbw.getBuildWrappersList()) { logger = bw.decorateLogger(target, logger); BuildWrapper wrapper=value.createBuildWrapper(Promotion.this); if (wrapper!=null){ Environment e = wrapper.setUp(Promotion.this, launcher, listener); if(e==null) return Result.FAILURE;
/** * Hudson defines a method {@link Builder#getDescriptor()}, which returns the corresponding * {@link Descriptor} object. Since we know that it's actually {@link DescriptorImpl}, override the method * and give a better return type, so that we can access {@link DescriptorImpl} methods more easily. This is * not necessary, but just a coding style preference. */ @Override public DescriptorImpl getDescriptor() { // see Descriptor javadoc for more about what a descriptor is. return (DescriptorImpl) super.getDescriptor(); }
/** * Gets the build wrapper descriptor by name. Primarily used for making them web-visible. */ public Descriptor<BuildWrapper> getBuildWrapper(String shortClassName) { return findDescriptor(shortClassName, BuildWrapper.all()); }
/** * {@link Action}s to be displayed in the job page. * * @param job * This object owns the {@link BuildWrapper}. The returned action will be added to this object. * @return * can be empty but never null * @since 1.341 */ public Collection<? extends Action> getProjectActions(AbstractProject job) { // delegate to getJobAction (singular) for backward compatible behavior Action a = getProjectAction(job); if (a==null) return Collections.emptyList(); return Collections.singletonList(a); }
/** * May be overridden but this will only take effect when used as a {@link BuildWrapper} on an {@link AbstractProject}. * <p>{@inheritDoc} * @since 1.608 */ @Override public void makeBuildVariables(AbstractBuild build, Map<String,String> variables) { super.makeBuildVariables(build, variables); }
/** * May be overridden but this will only take effect when used as a {@link BuildWrapper} on an {@link AbstractProject}. * <p>{@inheritDoc} * @since 1.608 */ @Override public void makeSensitiveBuildVariables(AbstractBuild build, Set<String> sensitiveVariables) { super.makeSensitiveBuildVariables(build, sensitiveVariables); // TODO determine if there is a meaningful way to generalize this; perhaps as a new [Run]Action recording sensitiveVariables? // Complicated by the fact that in principle someone could call getSensitiveBuildVariables *before* the wrapper starts and actually sets those variables, // though in practice the likely use cases would come later, and perhaps it is acceptable to omit the names of variables which are yet to be set. // Also unclear if there is any use case for calling this method after the build is done (or Jenkins is restarted); // most likely it is only used during the build itself. // Would be much cleaner if EnvVars itself recorded which keys had sensitive values. }
@Override public DescriptorImpl getDescriptor() { return (DescriptorImpl) super.getDescriptor(); }
/** * List up all {@link BuildWrapperDescriptor}s that are applicable for the given project. * * @return * The signature doesn't use {@link BuildWrapperDescriptor} to maintain compatibility * with {@link BuildWrapper} implementations before 1.150. */ public static List<Descriptor<BuildWrapper>> getFor(AbstractProject<?, ?> project) { List<Descriptor<BuildWrapper>> result = new ArrayList<>(); Descriptor pd = Jenkins.getInstance().getDescriptor((Class)project.getClass()); for (Descriptor<BuildWrapper> w : BuildWrapper.all()) { if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(w)) continue; if (w instanceof BuildWrapperDescriptor) { BuildWrapperDescriptor bwd = (BuildWrapperDescriptor) w; if(bwd.isApplicable(project)) result.add(bwd); } else { // old BuildWrapper that doesn't implement BuildWrapperDescriptor result.add(w); } } return result; } }
@Override public Action getProjectAction(AbstractProject job) { return super.getProjectAction(job); }
bw.makeBuildVariables(this,r);
/** * Builds up a set of variable names that contain sensitive values that * should not be exposed. The expectation is that this set is populated with * keys returned by {@link #getBuildVariables()} that should have their * values masked for display purposes. * * @since 1.378 */ public Set<String> getSensitiveBuildVariables() { Set<String> s = new HashSet<String>(); ParametersAction parameters = getAction(ParametersAction.class); if (parameters != null) { for (ParameterValue p : parameters) { if (p.isSensitive()) { s.add(p.getName()); } } } // Allow BuildWrappers to determine if any of their data is sensitive if (project instanceof BuildableItemWithBuildWrappers) { for (BuildWrapper bw : ((BuildableItemWithBuildWrappers) project).getBuildWrappersList()) { bw.makeSensitiveBuildVariables(this, s); } } return s; }
public Environment superSetUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { return super.setUp(build, launcher, listener); }
public Collection<? extends Action> superGetProjectActions(AbstractProject job) { return super.getProjectActions(job); }
@Override public OutputStream decorateLogger(AbstractBuild build, OutputStream logger) throws IOException, InterruptedException, Run.RunnerAbortedException { return super.decorateLogger(build, logger); }
@Override public DescriptorImpl getDescriptor() { return (DescriptorImpl) super.getDescriptor(); }
/** * Gets the build wrapper descriptor by name. Primarily used for making them web-visible. */ public Descriptor<BuildWrapper> getBuildWrapper(String shortClassName) { return findDescriptor(shortClassName, BuildWrapper.all()); }
public Action superGetProjectAction(AbstractProject job) { return super.getProjectAction(job); }