Java Code Examples for hudson.model.Run#getParent()
The following examples show how to use
hudson.model.Run#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildFlowAction.java From yet-another-build-visualizer-plugin with MIT License | 6 votes |
private static Run getUpstreamBuild(@Nonnull Run build) { CauseAction causeAction = build.getAction(CauseAction.class); if (causeAction == null) { return null; } for (Cause cause : causeAction.getCauses()) { if (cause instanceof Cause.UpstreamCause) { Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause; Job upstreamJob = Jenkins.getInstance().getItemByFullName(upstreamCause.getUpstreamProject(), Job.class); // We want to ignore rebuilds, rebuilds have the same parent as // original build, see BuildCache#updateCache(). if (upstreamJob == null || build.getParent() == upstreamJob) { continue; } return upstreamJob.getBuildByNumber(upstreamCause.getUpstreamBuild()); } } return null; }
Example 2
Source File: HistoryAggregatedFlakyTestResultAction.java From flaky-test-handler-plugin with Apache License 2.0 | 6 votes |
/** * Construct a SingleTestFlakyStatsWithRevision object with {@link SingleTestFlakyStats} and * build information. * * @param stats Embedded {@link SingleTestFlakyStats} object * @param build The {@link hudson.model.Run} object to get SCM information from. */ public SingleTestFlakyStatsWithRevision(SingleTestFlakyStats stats, Run build) { this.stats = stats; revision = Integer.toString(build.getNumber()); Job job = build.getParent(); SCMTriggerItem s = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job); if (s != null) { ArrayList<SCM> scms = new ArrayList<>(s.getSCMs()); SCM scm = scms.size() > 0 ? scms.get(0) : null; if (scm != null && "hudson.plugins.git.GitSCM".equalsIgnoreCase(scm.getType())) { GitSCM gitSCM = (GitSCM) scm; BuildData buildData = gitSCM.getBuildData(build); if (buildData != null) { Revision gitRevision = buildData.getLastBuiltRevision(); if (gitRevision != null) { revision = gitRevision.getSha1String(); } } } } }
Example 3
Source File: FolderConfig.java From docker-workflow-plugin with MIT License | 5 votes |
@Override public String getLabel(@Nullable Run run) { if (run != null) { Job job = run.getParent(); ItemGroup parent = job.getParent(); while (parent != null) { if (parent instanceof AbstractFolder) { AbstractFolder folder = (AbstractFolder) parent; FolderConfig config = (FolderConfig) folder.getProperties().get(FolderConfig.class); if (config != null) { String label = config.getDockerLabel(); if (!StringUtils.isBlank(label)) { return label; } } } if (parent instanceof Item) { parent = ((Item) parent).getParent(); } else { parent = null; } } } return null; }
Example 4
Source File: FolderConfig.java From docker-workflow-plugin with MIT License | 5 votes |
@Override public String getRegistryUrl(@Nullable Run run) { if (run != null) { Job job = run.getParent(); ItemGroup parent = job.getParent(); while (parent != null) { if (parent instanceof AbstractFolder) { AbstractFolder folder = (AbstractFolder) parent; FolderConfig config = (FolderConfig) folder.getProperties().get(FolderConfig.class); if (config != null) { DockerRegistryEndpoint registry = config.getRegistry(); if (registry != null && !StringUtils.isBlank(registry.getUrl())) { return registry.getUrl(); } } } if (parent instanceof Item) { parent = ((Item) parent).getParent(); } else { parent = null; } } } return null; }
Example 5
Source File: FolderConfig.java From docker-workflow-plugin with MIT License | 5 votes |
@Override public String getRegistryCredentialsId(@Nullable Run run) { if (run != null) { Job job = run.getParent(); ItemGroup parent = job.getParent(); while (parent != null) { if (parent instanceof AbstractFolder) { AbstractFolder folder = (AbstractFolder) parent; FolderConfig config = (FolderConfig) folder.getProperties().get(FolderConfig.class); if (config != null) { DockerRegistryEndpoint registry = config.getRegistry(); if (registry != null && !StringUtils.isBlank(registry.getCredentialsId())) { return registry.getCredentialsId(); } } } if (parent instanceof Item) { parent = ((Item) parent).getParent(); } else { parent = null; } } } return null; }
Example 6
Source File: PodTemplateStepExecution.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
/** * Check if the current Job is permitted to use the cloud. * * @param run * @param kubernetesCloud * @throws AbortException * in case the Job has not been authorized to use the * kubernetesCloud */ private void checkAccess(Run<?, ?> run, KubernetesCloud kubernetesCloud) throws AbortException { Job<?, ?> job = run.getParent(); // Return the associated Job for this Build ItemGroup<?> parent = job.getParent(); // Get the Parent of the Job (which might be a Folder) Set<String> allowedClouds = new HashSet<>(); KubernetesFolderProperty.collectAllowedClouds(allowedClouds, parent); if (!allowedClouds.contains(kubernetesCloud.name)) { throw new AbortException(String.format("Not authorized to use Kubernetes cloud: %s", step.getCloud())); } }
Example 7
Source File: DeflakeAction.java From flaky-test-handler-plugin with Apache License 2.0 | 5 votes |
/** * Handles the rebuild request and redirects to deflake config page * * @param request StaplerRequest the request. * @param response StaplerResponse the response handler. * @throws java.io.IOException in case of Stapler issues * @throws javax.servlet.ServletException if something unfortunate happens. * @throws InterruptedException if something unfortunate happens. */ public void doIndex(StaplerRequest request, StaplerResponse response) throws IOException, ServletException, InterruptedException { Run currentBuild = request.findAncestorObject(Run.class); if (currentBuild != null) { Job job = currentBuild.getParent(); job.checkPermission(AbstractProject.BUILD); response.sendRedirect(DEFLAKE_CONFIG_URL); } }
Example 8
Source File: GitLabConnectionProperty.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
public static GitLabClient getClient(@NotNull Run<?, ?> build) { Job<?, ?> job = build.getParent(); if(job != null) { final GitLabConnectionProperty connectionProperty = job.getProperty(GitLabConnectionProperty.class); if (connectionProperty != null) { return connectionProperty.getClient(); } } return null; }
Example 9
Source File: Dashboard.java From docker-swarm-plugin with MIT License | 4 votes |
private String getJobName(final Run build) { final Job parent = build.getParent(); return (parent.getParent() instanceof Job ? (Job) parent.getParent() : parent).getFullDisplayName(); }
Example 10
Source File: Office365ConnectorWebhookNotifier.java From office-365-connector-plugin with Apache License 2.0 | 4 votes |
public Office365ConnectorWebhookNotifier(Run run, TaskListener taskListener) { this.run = run; this.taskListener = taskListener; this.decisionMaker = new DecisionMaker(run, taskListener); this.job = run.getParent(); }
Example 11
Source File: Utils.java From lockable-resources-plugin with MIT License | 4 votes |
public static Job<?, ?> getProject(Run<?, ?> build) { Object p = build.getParent(); return (Job<?, ?>) p; }