public static String of(WorkflowRun build) { if (build == null) { return null; } return build.getParent().getFullName(); }
@Exported public String getFullJobName() { return workflowJob.getFullName(); }
public void onDeleted(WorkflowJob pipeline) { LOGGER.log(Level.FINE, "onDeleted({0})", pipeline); globalPipelineMavenConfig.getDao().deleteJob(pipeline.getFullName()); }
Owner(WorkflowRun run) { job = run.getParent().getFullName(); id = run.getId(); this.run = run; } private String key() {
private String key() { return getParent().getFullName() + '/' + getId(); }
@Override public void onStarted(WorkflowRun workflowRun, TaskListener listener) { WorkflowJob parent = workflowRun.getParent(); JiraSite site = JiraSite.get(parent); if (site != null) { try { setAction(parent, site); } catch (IOException e) { LOGGER.log(Level.WARNING, "Could not set JiraJobAction for <" + parent.getFullName() + ">", e); } } } }
public void onRenamed(WorkflowJob pipeline, String oldName, String newName) { LOGGER.log(Level.FINE, "onRenamed({0}, {1}, {2})", new Object[]{pipeline, oldName, newName}); String oldFullName; ItemGroup parent = pipeline.getParent(); if (parent.equals(Jenkins.getInstance())) { oldFullName = oldName; } else { oldFullName = parent.getFullName() + "/" + oldName; } String newFullName = pipeline.getFullName(); globalPipelineMavenConfig.getDao().renameJob(oldFullName, newFullName); }
public boolean isUpstreamBuildVisibleByDownstreamBuildAuth(@Nonnull WorkflowJob upstreamPipeline, @Nonnull Queue.Task downstreamPipeline) { Authentication auth = Tasks.getAuthenticationOf(downstreamPipeline); Authentication downstreamPipelineAuth; if (auth.equals(ACL.SYSTEM) && !QueueItemAuthenticatorConfiguration.get().getAuthenticators().isEmpty()) { downstreamPipelineAuth = Jenkins.ANONYMOUS; // cf. BuildTrigger } else { downstreamPipelineAuth = auth; } try (ACLContext ignored = ACL.as(downstreamPipelineAuth)) { WorkflowJob upstreamPipelineObtainedAsImpersonated = getItemByFullName(upstreamPipeline.getFullName(), WorkflowJob.class); boolean result = upstreamPipelineObtainedAsImpersonated != null; LOGGER.log(Level.FINE, "isUpstreamBuildVisibleByDownstreamBuildAuth({0}, {1}): taskAuth: {2}, downstreamPipelineAuth: {3}, upstreamPipelineObtainedAsImpersonated:{4}, result: {5}", new Object[]{upstreamPipeline, downstreamPipeline, auth, downstreamPipelineAuth, upstreamPipelineObtainedAsImpersonated, result}); return result; } }
candidate = LOADING_RUNS.get(key()); if (candidate != null && candidate.getParent().getFullName().equals(job) && candidate.getId().equals(id)) { run = candidate; } else {
@Override public void onDeleted(WorkflowRun run) { globalPipelineMavenConfig.getDao().deleteBuild(run.getParent().getFullName(), run.getNumber()); }
@Override public void onCompleted(WorkflowRun workflowRun, @Nonnull TaskListener listener) { super.onCompleted(workflowRun, listener); // Note: run.duration is zero in onCompleted(), do the substraction in this listener Result result = workflowRun.getResult(); if (result == null) { result = Result.SUCCESS; // FIXME more elegant handling } globalPipelineMavenConfig.getDao().updateBuildOnCompletion( workflowRun.getParent().getFullName(), workflowRun.getNumber(), result.ordinal, workflowRun.getStartTimeInMillis(), Math.max(System.currentTimeMillis() - workflowRun.getStartTimeInMillis(), 0)); // @see HUDSON-5844 } }
String upstreamPipelineFullName = upstreamPipeline.getFullName(); int upstreamBuildNumber = upstreamBuild.getNumber(); Map<MavenArtifact, SortedSet<String>> downstreamPipelinesByArtifact = globalPipelineMavenConfig.getDao().listDownstreamJobsByArtifact(upstreamPipelineFullName, upstreamBuildNumber); } else if (transitiveUpstreamPipeline.getFullName().equals(upstreamPipeline.getFullName())) { new Object[]{downstreamPipeline.isDisabled(), downstreamPipeline.isHoldOffBuildUntilSave(), downstreamPipeline.getFullName(), upstreamBuild.getFullDisplayName()}); continue; LOGGER.log(Level.FINE, "Skip triggering of downstream pipeline {0} from upstream build {1}: dependency trigger not configured", new Object[]{downstreamPipeline.getFullName(), upstreamBuild.getFullDisplayName()}); continue; LOGGER.log(Level.FINER, "upstreamPipeline (" + upstreamPipelineFullName + ", visibleByDownstreamBuildAuth: " + upstreamVisibleByDownstreamBuildAuth + "), " + " downstreamPipeline (" + downstreamPipeline.getFullName() + ", visibleByUpstreamBuildAuth: " + downstreamVisibleByUpstreamBuildAuth + "), " + "upstreamBuildAuth: " + Jenkins.getAuthentication()); new Object[]{downstreamPipeline.getFullName(), upstreamBuild.getFullDisplayName(), downstreamVisibleByUpstreamBuildAuth, upstreamVisibleByDownstreamBuildAuth});
@Override public void onInitialize(WorkflowRun run) { super.onInitialize(run); for (Cause cause: run.getCauses()) { if (cause instanceof Cause.UpstreamCause) { Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause; String upstreamJobName = upstreamCause.getUpstreamProject(); int upstreamBuildNumber = upstreamCause.getUpstreamBuild(); globalPipelineMavenConfig.getDao().recordBuildUpstreamCause(upstreamJobName, upstreamBuildNumber, run.getParent().getFullName(), run.getNumber()); } } }
logger.log(Level.FINE, "Skip triggering of non buildable (disabled: " + downstreamPipeline.isDisabled() + ", isHoldOffBuildUntilSave: " + downstreamPipeline.isHoldOffBuildUntilSave() + ") downstream pipeline " + downstreamPipeline.getFullName()); LOGGER.log(Level.FINE, "Skip triggering of downstream pipeline {0}: dependency trigger not configured", new Object[]{downstreamPipeline.getFullName()}); continue; LOGGER.log(Level.FINE, "Skip triggering of {0} by {1}", new Object[]{downstreamPipeline.getFullName(), cause});
private void verifyProject(WorkflowJob p) throws Exception { assertEquals("dev%2Fmain", p.getName()); assertEquals("dev/main", p.getDisplayName()); assertEquals("p/dev%2Fmain", p.getFullName()); assertEquals("p » dev/main", p.getFullDisplayName()); story.j.createWebClient().getPage(p); assertEquals(new File(new File(p.getParent().getRootDir(), "branches"), "dev-main.k31kdj"), p.getRootDir()); }
@Issue("JENKINS-45455") @Test public void projectNotBuildable() throws Exception { WorkflowRun original = expect(Result.FAILURE, "restart", "simpleRestart") .logContains("Odd numbered build, failing", "This shouldn't show up on second run") .go(); RestartDeclarativePipelineAction action = original.getAction(RestartDeclarativePipelineAction.class); assertNotNull(action); assertTrue(action.isRestartEnabled()); WorkflowJob p = original.getParent(); p.setDisabled(true); Exception runFailure = null; try { Queue.Item queueItem = action.run("restart"); // Because we should definitely have thrown an exception in run. assertNull(queueItem); } catch (Exception e) { runFailure = e; } assertNotNull(runFailure); assertTrue(runFailure instanceof IllegalStateException); assertEquals(Messages.RestartDeclarativePipelineAction_ProjectNotBuildable(p.getFullName()), runFailure.getMessage()); }