@Override public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException { GitLabWebHookCause cause = null; if (r instanceof MatrixRun) { MatrixBuild parent = ((MatrixRun)r).getParentBuild(); if (parent != null) { cause = (GitLabWebHookCause) parent.getCause(GitLabWebHookCause.class); } } else { cause = (GitLabWebHookCause) r.getCause(GitLabWebHookCause.class); } if (cause != null) { envs.overrideAll(cause.getData().getBuildVariables()); } } }
/** * The same as {@link #getParentBuild()}. */ @Override public AbstractBuild<?, ?> getRootBuild() { return getParentBuild(); }
@Override public void checkPermission(hudson.security.Permission p) { MatrixBuild parentBuild = getParentBuild(); if(parentBuild != null) { parentBuild.checkPermission(p); } };
@Override public void checkPermission(hudson.security.Permission p) { MatrixBuild parentBuild = getParentBuild(); if(parentBuild != null) { parentBuild.checkPermission(p); } };
@Override public void checkPermission(hudson.security.Permission p) { MatrixBuild parentBuild = getParentBuild(); if(parentBuild != null) { parentBuild.checkPermission(p); } };
@Override public void checkPermission(hudson.security.Permission p) { MatrixBuild parentBuild = getParentBuild(); if (parentBuild != null) { parentBuild.checkPermission(p); } }
private boolean isEligibleJobType(@Nonnull Run<?, ?> build) { final Job job; if (build instanceof MatrixRun) { job = ((MatrixRun) build).getParentBuild().getParent(); } else { job = build.getParent(); } return job instanceof BuildableItemWithBuildWrappers; }
/** * matrix-project requires special extraction. */ @CheckForNull public static <T extends Cause> T ghCauseFromRun(Run<?, ?> run, Class<T> tClass) { if (run instanceof MatrixRun) { MatrixBuild parentBuild = ((MatrixRun) run).getParentBuild(); if (nonNull(parentBuild)) { return parentBuild.getCause(tClass); } } else { return run.getCause(tClass); } return null; }
@Override public void onLoad(Run<?, ?> r) { if (r instanceof MatrixRun) { MatrixRun run = (MatrixRun) r; ParametersAction action = run.getParentBuild().getAction(ParametersAction.class); if (action != null) { // Parameters of build and its runs are guaranteed to be the same. Even the actual instances are the same // until it gets (re)loaded from disk when the parameters reside in memory 1+N times squandering memory. // This populates now volatile collection with parameters shared between the build and all its runs bringing // the space complexity back to 1. parameters = action.getParameters(); } else { parameters = Collections.emptyList(); } } }
@Nonnull public File getPollingLogFile() { File pollingFile; if (nonNull(job)) { pollingFile = job.getRootDir(); } else if (run instanceof MatrixRun) { MatrixRun matrixRun = (MatrixRun) run; pollingFile = matrixRun.getParentBuild().getRootDir(); } else if (run instanceof MatrixBuild) { pollingFile = run.getRootDir(); } else if (nonNull(run)) { pollingFile = run.getRootDir(); } else { throw new IllegalStateException("Can't get polling log file: no run or job initialised"); } return new File(pollingFile, getPollingFileName()); }
/** * If the parent {@link MatrixBuild} is kept, keep this record too. */ @Override public String getWhyKeepLog() { MatrixBuild pb = getParentBuild(); if(pb!=null && pb.getWhyKeepLog()!=null) return Messages.MatrixRun_KeptBecauseOfParent(pb); return super.getWhyKeepLog(); }
@CheckForNull private EnvInjectPasswordWrapper getEnvInjectPasswordWrapper(@Nonnull Run<?, ?> build) throws EnvInjectException { DescribableList<BuildWrapper, Descriptor<BuildWrapper>> wrappersProject; if (build instanceof MatrixRun) { MatrixProject project = ((MatrixRun) build).getParentBuild().getProject(); wrappersProject = project.getBuildWrappersList(); } else { final Job<?, ?> job = build.getParent(); if (job instanceof BuildableItemWithBuildWrappers) { BuildableItemWithBuildWrappers project = (BuildableItemWithBuildWrappers) job; wrappersProject = project.getBuildWrappersList(); } else { throw new EnvInjectException(String.format("Job type %s is not supported", job)); } } for (BuildWrapper buildWrapper : wrappersProject) { if (EnvInjectPasswordWrapper.class.equals(buildWrapper.getClass())) { return (EnvInjectPasswordWrapper) buildWrapper; } } return null; }
/** * If the parent {@link MatrixBuild} is kept, keep this record too. */ @Override public String getWhyKeepLog() { MatrixBuild pb = getParentBuild(); if(pb!=null && pb.getWhyKeepLog()!=null) return Messages.MatrixRun_KeptBecauseOfParent(pb); return super.getWhyKeepLog(); }
/** * If the parent {@link MatrixBuild} is kept, keep this record too. */ @Override public String getWhyKeepLog() { MatrixBuild pb = getParentBuild(); if(pb!=null && pb.getWhyKeepLog()!=null) return Messages.MatrixRun_KeptBecauseOfParent(pb); return super.getWhyKeepLog(); }
/** * If the parent {@link MatrixBuild} is kept, keep this record too. */ @Override public String getWhyKeepLog() { MatrixBuild pb = getParentBuild(); if(pb!=null && pb.getWhyKeepLog()!=null) return Messages.MatrixRun_KeptBecauseOfParent(pb); return super.getWhyKeepLog(); }
/** * If the parent {@link MatrixBuild} is kept, keep this record too. */ @Override public String getWhyKeepLog() { MatrixBuild pb = getParentBuild(); if (pb != null && pb.getWhyKeepLog() != null) { return Messages.MatrixRun_KeptBecauseOfParent(pb); } return super.getWhyKeepLog(); }
@CheckForNull @SuppressWarnings("unchecked") public static EnvInjectJobProperty getEnvInjectJobProperty(@Nonnull Run<?, ?> build) { if (build == null) { throw new IllegalArgumentException("A build object must be set."); } final Job job; if (build instanceof MatrixRun) { job = ((MatrixRun) build).getParentBuild().getParent(); } else { job = build.getParent(); } EnvInjectJobProperty envInjectJobProperty = (EnvInjectJobProperty) job.getProperty(EnvInjectJobProperty.class); if (envInjectJobProperty != null) { EnvInjectJobPropertyInfo info = envInjectJobProperty.getInfo(); if (info != null && envInjectJobProperty.isOn()) { return envInjectJobProperty; } } return null; }
private String getRevToBuild(AbstractBuild<?, ?> build, EnvVars env) { String revToBuild = getBranch(env); if (build instanceof MatrixRun) { MatrixRun matrixRun = (MatrixRun) build; MercurialTagAction parentRevision = matrixRun.getParentBuild().getAction(MercurialTagAction.class); if (parentRevision != null && parentRevision.getId() != null) { revToBuild = parentRevision.getId(); } } return revToBuild; }
private String getRevToBuild(Run<?, ?> build, FilePath workspace, EnvVars env) { String revToBuild = getRevision(env); if (build instanceof MatrixRun) { MatrixRun matrixRun = (MatrixRun) build; MercurialTagAction parentRevision = null; final Jenkins jenkins = Jenkins.getInstance(); if (jenkins != null && jenkins.getPlugin("multiple-scms") != null) { MultiSCMRevisionState parentRevisions = matrixRun.getParentBuild().getAction(MultiSCMRevisionState.class); if (parentRevisions != null) { SCMRevisionState _parentRevisions = parentRevisions.get(this, workspace, (MatrixRun) build); if (_parentRevisions instanceof MercurialTagAction) { parentRevision = (MercurialTagAction)_parentRevisions; } // otherwise fall-back to the default behavior } if (parentRevisions == null) { parentRevision = matrixRun.getParentBuild().getAction(MercurialTagAction.class); } } else { parentRevision = matrixRun.getParentBuild().getAction(MercurialTagAction.class); } if (parentRevision != null && parentRevision.getId() != null) { revToBuild = parentRevision.getId(); } } return revToBuild; }
protected Lease getParentWorkspaceLease(Node n, WorkspaceList wsl) throws InterruptedException, IOException { MatrixProject mp = getParent().getParent(); String customWorkspace = mp.getCustomWorkspace(); if (customWorkspace != null) { final FilePath nodeRoot = n.getRootPath(); if (nodeRoot == null) { throw new IOException("Cannot retrieve the node's root. Most probably it's offline"); } // we allow custom workspaces to be concurrently used between jobs. return Lease.createDummyLease(nodeRoot.child(getEnvironment(listener).expand(customWorkspace))); } final FilePath workspace = n.getWorkspaceFor(mp); if (workspace == null) { throw new IOException("Cannot retrieve the node's workspace for " + mp + ". Most probably the node is offline"); } return wsl.allocate(workspace, getParentBuild()); }