hudson.model.AbstractProject Java Examples
The following examples show how to use
hudson.model.AbstractProject.
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: JobHelper.java From github-integration-plugin with MIT License | 6 votes |
/** * support matrix plugin. * * @see JobInfoHelpers#triggerFrom(hudson.model.Job, java.lang.Class) */ @CheckForNull public static <T extends Trigger> T triggerFrom(final Job<?, ?> job, Class<T> tClass) { Job<?, ?> guessJob; if (job instanceof MatrixConfiguration) { guessJob = ((MatrixConfiguration) job).getParent(); } else { guessJob = job; } if (guessJob instanceof AbstractProject<?, ?>) { final AbstractProject<?, ?> abstractProject = (AbstractProject<?, ?>) guessJob; return abstractProject.getTrigger(tClass); } else if (guessJob instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) guessJob; for (Object candidate : pJob.getTriggers().values()) { if (tClass.isInstance(candidate)) { return tClass.cast(candidate); } } } return null; }
Example #2
Source File: AggregatedTestResultPublisher.java From junit-plugin with MIT License | 6 votes |
@SuppressWarnings("deprecation") // calls getProject in constructor, so needs owner immediately public TestResultAction(String jobs, boolean includeFailedBuilds, AbstractBuild<?,?> owner) { super(owner); this.includeFailedBuilds = includeFailedBuilds; if(jobs==null) { // resolve null as the transitive downstream jobs StringBuilder buf = new StringBuilder(); for (AbstractProject p : getProject().getTransitiveDownstreamProjects()) { if(buf.length()>0) buf.append(','); buf.append(p.getFullName()); } jobs = buf.toString(); } this.jobs = jobs; }
Example #3
Source File: ModelValidation.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Performs on-the-fly validation on the ant pattern for input files. * * @param project * the project * @param pattern * the file pattern * * @return the validation result */ public FormValidation doCheckPattern(@AncestorInPath final AbstractProject<?, ?> project, @QueryParameter final String pattern) { if (project != null) { // there is no workspace in pipelines try { FilePath workspace = project.getSomeWorkspace(); if (workspace != null && workspace.exists()) { return validatePatternInWorkspace(pattern, workspace); } } catch (InterruptedException | IOException ignore) { // ignore and return ok } } return FormValidation.ok(); }
Example #4
Source File: ModelValidation.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Performs on-the-fly validation on the source code directory. * * @param project * the project * @param sourceDirectory * the file pattern * * @return the validation result */ public FormValidation doCheckSourceDirectory(@AncestorInPath final AbstractProject<?, ?> project, @QueryParameter final String sourceDirectory) { if (project != null) { // there is no workspace in pipelines try { FilePath workspace = project.getSomeWorkspace(); if (workspace != null && workspace.exists()) { return validateRelativePath(sourceDirectory, workspace); } } catch (InterruptedException | IOException ignore) { // ignore and return ok } } return FormValidation.ok(); }
Example #5
Source File: Disabler.java From blueocean-plugin with MIT License | 5 votes |
public static void makeDisabled(Object item, boolean b) throws IOException { if (item instanceof AbstractFolder) { Disabler.makeDisabled((AbstractFolder) item, b); } if (item instanceof AbstractProject) { Disabler.makeDisabled((AbstractProject) item, b); } if (item instanceof ParameterizedJobMixIn.ParameterizedJob ) { Disabler.makeDisabled((ParameterizedJobMixIn.ParameterizedJob ) item, b); } }
Example #6
Source File: TemplateProjectListener.java From ez-templates with Apache License 2.0 | 5 votes |
@Override public void onUpdated(Item item) { TemplateProperty property = getTemplateProperty(item); if (property != null) { try { TemplateUtils.handleTemplateSaved((AbstractProject) item, property); } catch (Exception e) { throw Throwables.propagate(e); } } }
Example #7
Source File: TemplateProjectListener.java From ez-templates with Apache License 2.0 | 5 votes |
/** * @param item A changed project * @return null if this is not a template project */ private static TemplateProperty getTemplateProperty(Item item) { if (item instanceof AbstractProject) { return (TemplateProperty) ((AbstractProject) item).getProperty(TemplateProperty.class); } return null; }
Example #8
Source File: DbBackedBuild.java From DotCi with MIT License | 5 votes |
@Deprecated // Keeping this so we can more easily migrate from existing systems public void restoreFromDb(final AbstractProject project, final Map<String, Object> input) { this.id = (ObjectId) input.get("_id"); final String state = ((String) input.get("state")); setField(getState(state), "state"); final Date date = ((Date) input.get("last_updated")); setField(date.getTime(), "timestamp"); setField(project, "project"); super.onLoad(); }
Example #9
Source File: DockerSwarmComputerLauncher.java From docker-swarm-plugin with MIT License | 5 votes |
public DockerSwarmComputerLauncher(final Queue.BuildableItem bi) { super(DockerSwarmCloud.get().getTunnel(), null, new RemotingWorkDirSettings(false, "/tmp", null, false)); this.bi = bi; this.label = bi.task.getAssignedLabel().getName(); this.jobName = bi.task instanceof AbstractProject ? ((AbstractProject) bi.task).getFullName() : bi.task.getName(); }
Example #10
Source File: AWSDeviceFarmUtils.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Returns the most recent build which contained an AWS Device Farm test run. * * @param project The Jenkins project which contains runs to examine. * @return The previous Device Farm build. */ public static AbstractBuild<?, ?> previousAWSDeviceFarmBuild(AbstractProject<?, ?> project) { AbstractBuild<?, ?> last = project.getLastBuild(); while (last != null) { if (last.getAction(AWSDeviceFarmTestResultAction.class) != null) { break; } last = last.getPreviousBuild(); } return last; }
Example #11
Source File: TemplateImplementationProjectListener.java From ez-templates with Apache License 2.0 | 5 votes |
/** * @param item A changed project * @return null if this is not a template implementation project */ private static TemplateImplementationProperty getTemplateImplementationProperty(Item item) { if (item instanceof AbstractProject) { return (TemplateImplementationProperty) ((AbstractProject) item).getProperty(TemplateImplementationProperty.class); } return null; }
Example #12
Source File: TemplateProperty.java From ez-templates with Apache License 2.0 | 5 votes |
public static Collection<AbstractProject> getImplementations(final String templateFullName) { Collection<AbstractProject> projects = ProjectUtils.findProjectsWithProperty(TemplateImplementationProperty.class); return Collections2.filter(projects, new Predicate<AbstractProject>() { public boolean apply(AbstractProject abstractProject) { TemplateImplementationProperty prop = (TemplateImplementationProperty) abstractProject.getProperty(TemplateImplementationProperty.class); return templateFullName.equals(prop.getTemplateJobName()); } }); }
Example #13
Source File: Disabler.java From blueocean-plugin with MIT License | 5 votes |
@SuppressFBWarnings(value = "NP_BOOLEAN_RETURN_NULL", justification = "isDisabled will return null if the job type doesn't support it") public static Boolean isDisabled(Object item) { if (item instanceof AbstractFolder) { return Disabler.isDisabled((AbstractFolder) item); } if (item instanceof AbstractProject) { return Disabler.isDisabled((AbstractProject) item); } if (item instanceof ParameterizedJobMixIn.ParameterizedJob ) { return Disabler.isDisabled((ParameterizedJobMixIn.ParameterizedJob ) item); } return null; }
Example #14
Source File: AWSCodePipelineSCM.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 5 votes |
@Override protected PollingResult compareRemoteRevisionWith( final AbstractProject<?, ?> project, final Launcher launcher, final FilePath filePath, final TaskListener listener, final SCMRevisionState revisionState) throws IOException, InterruptedException { final ActionTypeId actionTypeId = new ActionTypeId() .withCategory(actionTypeCategory) .withOwner(ActionOwner.Custom) .withProvider(actionTypeProvider) .withVersion(actionTypeVersion); final String projectName = Validation.sanitize(project.getName().trim()); LoggingHelper.log(listener, "Polling for jobs for action type id: [" + "Owner: %s, Category: %s, Provider: %s, Version: %s, ProjectName: %s]", actionTypeId.getOwner(), actionTypeId.getCategory(), actionTypeId.getProvider(), actionTypeId.getVersion(), project.getName()); return pollForJobs(projectName, actionTypeId, listener); }
Example #15
Source File: TestNotifier.java From jenkins-test-harness with MIT License | 5 votes |
@Override public BuildStepDescriptor<Publisher> getDescriptor() { return new BuildStepDescriptor<Publisher>() { @Override public boolean isApplicable(Class<? extends AbstractProject> jobType) { return true; } }; }
Example #16
Source File: ProjectUtils.java From ez-templates with Apache License 2.0 | 5 votes |
/** * Get a project by its fullName (including any folder structure if present). * Temporarily also allows a match by name if one exists. */ public static AbstractProject findProject(String fullName) { List<AbstractProject> projects = Jenkins.getInstance().getAllItems(AbstractProject.class); AbstractProject nameOnlyMatch = null; // marc: 20140831, Remove compat patch for users upgrading for (AbstractProject project : projects) { if (fullName.equals(project.getFullName())) { return project; } if (fullName.equals(project.getName())) { nameOnlyMatch = project; } } return nameOnlyMatch; }
Example #17
Source File: ParameterizedTimerTrigger.java From parameterized-scheduler with MIT License | 5 votes |
@Override public void start(AbstractProject project, boolean newInstance) { this.job = project; try {// reparse the tabs with the job as the hash cronTabList = ParameterizedCronTabList.create(parameterizedSpecification, Hash.from(project.getFullName())); } catch (ANTLRException e) { // this shouldn't fail because we've already parsed stuff in the constructor, // so if it fails, use whatever 'tabs' that we already have. LOGGER.log(Level.FINE, "Failed to parse crontab spec: " + spec, e); } }
Example #18
Source File: TestUtility.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
static AbstractBuild mockSimpleBuild(String gitLabConnection, Result result, String... remoteUrls) { AbstractBuild build = mock(AbstractBuild.class); BuildData buildData = mock(BuildData.class); when(buildData.getRemoteUrls()).thenReturn(new HashSet<>(Arrays.asList(remoteUrls))); when(build.getAction(BuildData.class)).thenReturn(buildData); when(build.getResult()).thenReturn(result); when(build.getUrl()).thenReturn(BUILD_URL); when(build.getResult()).thenReturn(result); when(build.getNumber()).thenReturn(BUILD_NUMBER); AbstractProject<?, ?> project = mock(AbstractProject.class); when(project.getProperty(GitLabConnectionProperty.class)).thenReturn(new GitLabConnectionProperty(gitLabConnection)); when(build.getProject()).thenReturn(project); return build; }
Example #19
Source File: TemplateImplementationProjectListener.java From ez-templates with Apache License 2.0 | 5 votes |
@Override public void onUpdated(Item item) { TemplateImplementationProperty property = getTemplateImplementationProperty(item); if (property != null) { try { TemplateUtils.handleTemplateImplementationSaved((AbstractProject) item, property); } catch (Exception e) { throw Throwables.propagate(e); } } }
Example #20
Source File: TemplateImplementationProperty.java From ez-templates with Apache License 2.0 | 5 votes |
/** * Jenkins-convention to populate the drop-down box with discovered templates */ @SuppressWarnings("UnusedDeclaration") public ListBoxModel doFillTemplateJobNameItems() { ListBoxModel items = new ListBoxModel(); // Add null as first option - dangerous to force an existing project onto a template in case // a noob destroys their config items.add(Messages.TemplateImplementationProperty_noTemplateSelected(), null); // Add all discovered templates for (AbstractProject project : ProjectUtils.findProjectsWithProperty(TemplateProperty.class)) { // fullName includes any folder structure items.add(project.getFullDisplayName(), project.getFullName()); } return items; }
Example #21
Source File: AWSClientFactoryTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 5 votes |
@Test(expected=InvalidInputException.class) public void testNonExistentCreds() { String credentialsId = "folder-creds"; String folder = "folder"; when(CredentialsMatchers.firstOrNull(any(Iterable.class), any(CredentialsMatcher.class))).thenReturn(null); Jenkins mockInstance = mock(Jenkins.class); Item mockFolder = mock(Item.class); PowerMockito.mockStatic(Jenkins.class); when(Jenkins.getInstance()).thenReturn(mockInstance); when(mockInstance.getItemByFullName(credentialsId)).thenReturn(mockFolder); PowerMockito.mockStatic(CredentialsProvider.class); AbstractProject mockProject = mock(AbstractProject.class); ItemGroup mockFolderItem = mock(ItemGroup.class); when(build.getParent()).thenReturn(mockProject); when(mockProject.getParent()).thenReturn(mockFolderItem); when(mockFolder.getFullName()).thenReturn(folder); try { new AWSClientFactory("jenkins", credentialsId, "", "", "", null, "", REGION, build, null); } catch (InvalidInputException e) { assert(e.getMessage().contains(CodeBuilderValidation.invalidCredentialsIdError)); throw e; } }
Example #22
Source File: MattermostListener.java From jenkins-mattermost-plugin with MIT License | 5 votes |
@SuppressWarnings("unchecked") FineGrainedNotifier getNotifier(AbstractProject project, TaskListener listener) { Map<Descriptor<Publisher>, Publisher> map = project.getPublishersList().toMap(); for (Publisher publisher : map.values()) { if (publisher instanceof MattermostNotifier) { return new ActiveNotifier((MattermostNotifier) publisher, (BuildListener) listener, new JenkinsTokenExpander(listener)); } } return new DisabledNotifier(); }
Example #23
Source File: OpenShiftCreator.java From jenkins-plugin with Apache License 2.0 | 4 votes |
@Override public Action getProjectAction(AbstractProject<?, ?> project) { return null; }
Example #24
Source File: DockerBuilderPublisher.java From docker-plugin with MIT License | 4 votes |
@Override public boolean isApplicable(Class<? extends AbstractProject> jobType) { return true; }
Example #25
Source File: DockerBuildImageStep.java From yet-another-docker-plugin with MIT License | 4 votes |
@Override public boolean isApplicable(Class<? extends AbstractProject> jobType) { return true; }
Example #26
Source File: BuildStateRecipe.java From jenkins-build-monitor-plugin with MIT License | 4 votes |
public BuildStateRecipe() { build = PowerMockito.mock(AbstractBuild.class); AbstractProject parent = mock(AbstractProject.class); doReturn(parent).when(build).getParent(); }
Example #27
Source File: RepairnatorPostBuild.java From repairnator with MIT License | 4 votes |
@Override public Action getProjectAction(AbstractProject<?, ?> project) { return null; }
Example #28
Source File: RepairnatorPostBuild.java From repairnator with MIT License | 4 votes |
public boolean isApplicable(Class<? extends AbstractProject> aClass) { return true; }
Example #29
Source File: TemplateImplementationProperty.java From ez-templates with Apache License 2.0 | 4 votes |
public AbstractProject findTemplate() { return ProjectUtils.findProject(getTemplateJobName()); }
Example #30
Source File: TestResultProjectAction.java From junit-plugin with MIT License | 4 votes |
/** * @since 1.2-beta-1 */ public TestResultProjectAction(Job<?,?> job) { this.job = job; project = job instanceof AbstractProject ? (AbstractProject) job : null; }