private static boolean hasLastBuild(BuildData data) { return data != null && data.lastBuild != null && data.lastBuild.getRevision() != null; } }
private static String getBuildRevision(Run<?, ?> build) { GitLabWebHookCause cause = build.getCause(GitLabWebHookCause.class); if (cause != null) { return cause.getData().getLastCommit(); } BuildData action = build.getAction(BuildData.class); if (action == null) { throw new IllegalStateException("No (git-plugin) BuildData associated to current build"); } Revision lastBuiltRevision = action.getLastBuiltRevision(); if (lastBuiltRevision == null) { throw new IllegalStateException("Last build has no associated commit"); } return action.getLastBuild(lastBuiltRevision.getSha1()).getMarked().getSha1String(); }
addGitLabBranchBuild(result, getBuildRevision(build), buildDatas.get(0).getRemoteUrls(), environment, gitLabClient); } else { final SCMRevisionAction scmRevisionAction = build.getAction(SCMRevisionAction.class); for (final Entry<String, Build> buildByBranchName : buildData.getBuildsByBranchName().entrySet()) { if (buildByBranchName.getValue().getSHA1().equals(ObjectId.fromString(scmRevisionHash))) { addGitLabBranchBuild(result, scmRevisionHash, buildData.getRemoteUrls(), environment, gitLabClient);
/** * Short-hand to get to the display name. * @return display name of this build chooser */ public final String getDisplayName() { return getDescriptor().getDisplayName(); }
public void incomingMessageThread() throws FileNotFoundException, IOException { new Thread() { public void run() { BuildData a = new BuildData(); for(int i = 0; i<100; i++) { a.parseDataFile("_"+i+"/outgoingMessages"); } } }.start(); }
public List<BuildChooserDescriptor> getBuildChooserDescriptors() { return BuildChooser.all(); }
public <T> T actOnBuild(ContextCallable<Run<?,?>, T> callable) throws IOException, InterruptedException { return callable.invoke(build,Hudson.MasterComputer.localChannel); }
public static Run<?, ?> getBuildBySHA1IncludingMergeBuilds(Job<?, ?> project, String sha1) { for (Run<?, ?> build : project.getBuilds()) { for(BuildData data : build.getActions(BuildData.class)) { if (data != null && data.lastBuild != null && data.lastBuild.getMarked() != null && data.lastBuild.getMarked().getSha1String().equals(sha1)) { return build; } } } return null; }
public BuildChooser getBuildChooser() { if (buildChooser==null) buildChooser = new DefaultBuildChooser(); return buildChooser; }
public static EnvVars getPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { return getPollEnvironment(p, ws, launcher, listener, true); }
public static Run<?, ?> getBuildBySHA1WithoutMergeBuilds(Job<?, ?> project, String sha1) { for (Run<?, ?> build : project.getBuilds()) { MergeRecord merge = build.getAction(MergeRecord.class); for(BuildData data : build.getActions(BuildData.class)) { if (hasLastBuild(data) && isNoMergeBuild(data, merge) && data.lastBuild.isFor(sha1)) { return build; } } } return null; }
/** * Return true if the history shows this SHA1 has been built. * False otherwise. * @param sha1 SHA1 hash of commit * @return true if sha1 has been built */ public boolean hasBeenBuilt(ObjectId sha1) { return getLastBuild(sha1) != null; }
/** * Short-hand to get to the display name. */ public final String getDisplayName() { return getDescriptor().getDisplayName(); }
public static Run<?, ?> getBuildByBranch(Job<?, ?> project, String branchName) { for (Run<?, ?> build : project.getBuilds()) { BuildData data = build.getAction(BuildData.class); MergeRecord merge = build.getAction(MergeRecord.class); if (hasLastBuild(data) && isNoMergeBuild(data, merge)) { for (Branch branch : data.lastBuild.getRevision().getBranches()) { if (branch.getName().endsWith("/" + branchName)) { return build; } } } } return null; }
public List<BuildChooserDescriptor> getBuildChooserDescriptors() { return BuildChooser.all(); }
public <T> T actOnProject(ContextCallable<Job<?,?>, T> callable) throws IOException, InterruptedException { return callable.invoke(project, MasterComputer.localChannel); }
/** * Short-hand to get to the display name. */ public final String getDisplayName() { return getDescriptor().getDisplayName(); }
/** * Perform some closure, executing on the build * @param <T> The return type from the closure * @param callable the closure to run * @throws IOException if IO cannot be performed * @throws InterruptedException if the process is interrupted * @return closure return value */ public <T> T actOnBuild(ContextCallable<Run<?, ?>, T> callable) throws IOException, InterruptedException { return callable.invoke(build, Hudson.MasterComputer.localChannel); }
/** * Perform some closure, executing on the project * @param <T> The return type from the closure * @param callable the closure to run * @throws IOException if IO cannot be performed * @throws InterruptedException if the process is interrupted * @return closure return value */ public <T> T actOnProject(ContextCallable<Job<?, ?>, T> callable) throws IOException, InterruptedException { return callable.invoke(project, Hudson.MasterComputer.localChannel); }