當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractProject類代碼示例

本文整理匯總了Java中hudson.model.AbstractProject的典型用法代碼示例。如果您正苦於以下問題:Java AbstractProject類的具體用法?Java AbstractProject怎麽用?Java AbstractProject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbstractProject類屬於hudson.model包,在下文中一共展示了AbstractProject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jobLoaded

import hudson.model.AbstractProject; //導入依賴的package包/類
@Initializer(before = InitMilestone.COMPLETED, after = InitMilestone.JOB_LOADED)
public static void jobLoaded() throws IOException
{
	m_logger.fine("Initialization milestone: All jobs have been loaded"); //$NON-NLS-1$
	Jenkins jenkins = Jenkins.getInstance();
	for (AbstractProject<?, ?> project : jenkins.getAllItems(AbstractProject.class))
	{
		try
		{
			SCM scmConfig = project.getScm();
			if (scmConfig instanceof AbstractConfiguration && ((AbstractConfiguration) scmConfig).isMigrated())
			{
				project.save();

				m_logger.info(String.format(
								"Project %s has been migrated.", //$NON-NLS-1$
								project.getFullName()));
			}
		}
		catch (IOException e)
		{
			m_logger.log(Level.SEVERE, String.format("Failed to upgrade job %s", project.getFullName()), e); //$NON-NLS-1$
		}
	}
}
 
開發者ID:jenkinsci,項目名稱:compuware-scm-downloader-plugin,代碼行數:26,代碼來源:AbstractConfiguration.java

示例2: doCheckLocalPath

import hudson.model.AbstractProject; //導入依賴的package包/類
public FormValidation doCheckLocalPath(@AncestorInPath final AbstractProject project,
                                       @QueryParameter final String localPath) {
    final String path = Util.fixEmptyAndTrim(localPath);
    if (StringUtils.isBlank(path)) {
        return FormValidation.ok();
    }

    try {
        File f = resolvePath(project, localPath);
        if (f != null) {
            return FormValidation.ok();
        }
    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }

    return FormValidation.error("Invalid path.");
}
 
開發者ID:jenkinsci,項目名稱:browserstack-integration-plugin,代碼行數:19,代碼來源:BrowserStackBuildWrapperDescriptor.java

示例3: testGetProjectActionHavingLastBuildGivesStarWarsAction

import hudson.model.AbstractProject; //導入依賴的package包/類
public void testGetProjectActionHavingLastBuildGivesStarWarsAction() {
	AbstractProject mockProject = mock(AbstractProject.class);
	Build mockBuild = mock(Build.class);
	Quote expectedQuote = generateQuote(StarWarsResult.SUCCESS);

	when(mockProject.getLastBuild()).thenReturn(mockBuild);
	when(mockBuild.getResult()).thenReturn(Result.SUCCESS);
	
	when(mockQuotesGenerator.generate(StarWarsResult.SUCCESS)).thenReturn(expectedQuote);

	Action action = recorder.getProjectAction(mockProject);

	assertTrue(action instanceof StarWarsAction);
	assertEquals(StarWarsResult.SUCCESS, ((StarWarsAction) action).getResult());
	assertNotNull(((StarWarsAction) action).getQuote());
}
 
開發者ID:pedrolopesme,項目名稱:starwars-plugin,代碼行數:17,代碼來源:StarWarsRecorderTest.java

示例4: Ghprc

import hudson.model.AbstractProject; //導入依賴的package包/類
public Ghprc(AbstractProject<?, ?> project, GhprcTrigger trigger, ConcurrentMap<Integer, GhprcPullRequest> pulls) {
    this.project = project;

    final GithubProjectProperty ghpp = project.getProperty(GithubProjectProperty.class);
    if (ghpp == null || ghpp.getProjectUrl() == null) {
        throw new IllegalStateException("A GitHub project url is required.");
    }
    String baseUrl = ghpp.getProjectUrl().baseUrl();
    Matcher m = githubUserRepoPattern.matcher(baseUrl);
    if (!m.matches()) {
        throw new IllegalStateException(String.format("Invalid GitHub project url: %s", baseUrl));
    }
    final String user = m.group(2);
    final String repo = m.group(3);

    this.trigger = trigger;

    this.repository = new GhprcRepository(user, repo, this, pulls);
    this.builds = new GhprcBuilds(trigger, repository);
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:21,代碼來源:Ghprc.java

示例5: triggerFrom

import hudson.model.AbstractProject; //導入依賴的package包/類
/**
 * 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 (Trigger candidate : pJob.getTriggers().values()) {
            if (tClass.isInstance(candidate)) {
                return tClass.cast(candidate);
            }
        }
    }
    return null;
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:29,代碼來源:JobHelper.java

示例6: getWebHooks

import hudson.model.AbstractProject; //導入依賴的package包/類
private Set<GhprcWebHook> getWebHooks() {
    final Set<GhprcWebHook> webHooks = new HashSet<GhprcWebHook>();

    // We need this to get access to list of repositories
    Authentication old = SecurityContextHolder.getContext().getAuthentication();
    SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM);

    try {
        for (AbstractProject<?, ?> job : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
            GhprcTrigger trigger = job.getTrigger(GhprcTrigger.class);
            if (trigger == null || trigger.getWebHook() == null) {
                continue;
            }
            webHooks.add(trigger.getWebHook());
        }
    } finally {
        SecurityContextHolder.getContext().setAuthentication(old);
    }

    if (webHooks.size() == 0) {
        logger.log(Level.WARNING, "No projects found using GitHub pull request trigger");
    }

    return webHooks;
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:26,代碼來源:GhprcRootAction.java

示例7: compareRemoteRevisionWith

import hudson.model.AbstractProject; //導入依賴的package包/類
@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);

    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(),
            projectName);

    return pollForJobs(actionTypeId, listener);
}
 
開發者ID:awslabs,項目名稱:aws-codepipeline-plugin-for-jenkins,代碼行數:26,代碼來源:AWSCodePipelineSCM.java

示例8: gatherEnvVarsNode

import hudson.model.AbstractProject; //導入依賴的package包/類
@Nonnull
private static Map<String, String> gatherEnvVarsNode(@Nonnull Job<?, ?> job, @Nonnull Node node) throws EnvInjectException {
    
    final FilePath rootPath = node.getRootPath();
    if (rootPath == null) {
        //TODO: better than the original NPE. But maybe it's preferable to have more intelligent handling
        throw new EnvInjectException("Cannot retrieve Environment variables from the offline node");
    }
    
    try {
        Map<String, String> envVars = new EnvVars(rootPath.act(new MasterToSlaveCallable<Map<String, String>, EnvInjectException>() {
            private static final long serialVersionUID = 1L;
               
            @Override
            public Map<String, String> call() throws EnvInjectException {
                return EnvVars.masterEnvVars;
            }
        }));

        envVars.put("NODE_NAME", node.getNodeName());
        envVars.put("NODE_LABELS", Util.join(node.getAssignedLabels(), " "));
        
        if (job instanceof AbstractProject) {
            FilePath wFilePath = ((AbstractProject)job).getSomeWorkspace();
            if (wFilePath != null) {
                envVars.put("WORKSPACE", wFilePath.getRemote());
            }
        }

        return envVars;

    } catch (IOException | InterruptedException ioe) {
        throw new EnvInjectException(ioe);
    }
}
 
開發者ID:jenkinsci,項目名稱:envinject-api-plugin,代碼行數:36,代碼來源:EnvVarsResolver.java

示例9: createSqsJob

import hudson.model.AbstractProject; //導入依賴的package包/類
@Override
public SQSJob createSqsJob(Job job, SQSTrigger sqsTrigger) {
    SQSJob sqsJob = null;
    if (job instanceof AbstractProject) {
        sqsJob = new SQSAbstractProjectJob((AbstractProject) job, sqsTrigger);
    }
    else if (job instanceof WorkflowJob) {
        sqsJob = new SQSWorkflowJob((WorkflowJob) job, sqsTrigger);
    }
    return sqsJob;
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:12,代碼來源:SQSJobFactoryImpl.java

示例10: isApplicable

import hudson.model.AbstractProject; //導入依賴的package包/類
@Override
@SuppressWarnings("rawtypes")
public boolean isApplicable(Class<? extends AbstractProject> aClass)
{
	// Indicates that this builder can be used with all kinds of project types
	return true;
}
 
開發者ID:Compuware-Corp,項目名稱:CPWR-CodeCoverage,代碼行數:8,代碼來源:CodeCoverageBuilder.java

示例11: compareRemoteRevisionWith

import hudson.model.AbstractProject; //導入依賴的package包/類
/**
 * See documentation top of class
 * This function will determine the state of the artifactory server and compare it with the
 * local state. If there is a condition where a build needs to be triggered, trigger a build
 */
@Override
public PollingResult compareRemoteRevisionWith(AbstractProject<?,?> project,
    Launcher launcher, FilePath workspace, TaskListener listener, 
    SCMRevisionState baseline) throws IOException, InterruptedException
{
    LOGGER.log(FINE, "Comparing remote revisions with baseline");
    
    ArtifactoryRevisionState localState = (ArtifactoryRevisionState) baseline;

    ArtifactoryAPI api = new ArtifactoryAPI(getDescriptor().getArtifactoryServer());

    ArtifactoryRevisionState serverState = ArtifactoryRevisionState.fromServer(repo, groupID, artifactID, versionFilter, api);

    //Compare server state to local state
    nextArtifact = ArtifactoryRevisionState.compareRevisionStates(serverState, localState);
    if (nextArtifact != null)
    {
        LOGGER.log(FINE, "Found new data for version: " + nextArtifact);
        return PollingResult.BUILD_NOW;
    }

    // Compare local state to server state
    nextArtifact = ArtifactoryRevisionState.compareRevisionStates(localState, serverState);
    if (nextArtifact != null)
    {
        LOGGER.log(FINE, "Found new data for version: " + nextArtifact);
        return PollingResult.BUILD_NOW;
    }

    return PollingResult.NO_CHANGES;
}
 
開發者ID:pason-systems,項目名稱:jenkins-artifactory-polling-plugin,代碼行數:37,代碼來源:ArtifactoryRepository.java

示例12: dir

import hudson.model.AbstractProject; //導入依賴的package包/類
@Override
protected File dir() {
    if (item instanceof AbstractProject) {
        Run<?, ?> run = getAbstractProject().getLastCompletedBuild();
        if (run != null) {
            File buildArchiveDir = getBuildArchiveDir(run);
            if (buildArchiveDir.exists()) {
                return buildArchiveDir;
            }
        }
    }
    return getProjectArchiveDir(item);
}
 
開發者ID:DonutReport,項目名稱:donut-jenkins-plugin,代碼行數:14,代碼來源:DonutProjectAction.java

示例13: testUploadSource

import hudson.model.AbstractProject; //導入依賴的package包/類
@Test
public void testUploadSource() throws Exception {
    SCM mockSCM = mock(SCM.class);
    when(mockSCM.getType()).thenReturn("SCM");
    AbstractProject p = mock(AbstractProject.class);
    when(p.getScm()).thenReturn(mockSCM);
    when(build.getProject()).thenReturn(p);
    S3DataManager d = createDefaultSource();
    File sourceFolder = new File("/tmp/jenkins/workspace/proj");
    sourceFolder.mkdirs();
    UploadToS3Output result = d.uploadSourceToS3(listener, testWorkSpace);
    assertEquals(result.getSourceLocation(), s3InputBucketName + "/" + s3InputKeyName);
}
 
開發者ID:awslabs,項目名稱:aws-codebuild-jenkins-plugin,代碼行數:14,代碼來源:S3DataManagerTest.java

示例14: notifyStart

import hudson.model.AbstractProject; //導入依賴的package包/類
private void notifyStart(AbstractBuild build, String message) {
    try {
        AbstractProject<?, ?> project = build.getProject();
        AbstractBuild<?, ?> previousBuild = project.getLastBuild().getPreviousCompletedBuild();
        getTelegram(build).publish(message, getBuildColor(previousBuild));
    }
    catch (NullPointerException npe){
        getTelegram(build).publish(message, "good");
    }
}
 
開發者ID:FluffyFairyGames,項目名稱:jenkins-telegram-plugin,代碼行數:11,代碼來源:ActiveNotifier.java

示例15: completed

import hudson.model.AbstractProject; //導入依賴的package包/類
public void completed(AbstractBuild r) {
    AbstractProject<?, ?> project = r.getProject();
    if(project == null) return;
    Result result = r.getResult();
    AbstractBuild<?, ?> previousBuild = project.getLastBuild();
    if(previousBuild == null) return;
    do {
        previousBuild = previousBuild.getPreviousCompletedBuild();
    } while (previousBuild != null && previousBuild.getResult() == Result.ABORTED);
    Result previousResult = (previousBuild != null) ? previousBuild.getResult() : Result.SUCCESS;
    if ((result == Result.ABORTED && notifier.getNotifyAborted())
            || (result == Result.FAILURE //notify only on single failed build
                && previousResult != Result.FAILURE
                && notifier.getNotifyFailure())
            || (result == Result.FAILURE //notify only on repeated failures
                && previousResult == Result.FAILURE
                && notifier.getNotifyRepeatedFailure())
            || (result == Result.NOT_BUILT && notifier.getNotifyNotBuilt())
            || (result == Result.SUCCESS
                && (previousResult == Result.FAILURE || previousResult == Result.UNSTABLE)
                && notifier.getNotifyBackToNormal())
            || (result == Result.SUCCESS && notifier.getNotifySuccess())
            || (result == Result.UNSTABLE && notifier.getNotifyUnstable())) {
        getTelegram(r).publish(getBuildStatusMessage(r, notifier.includeTestSummary(),
                notifier.getIncludeFailedTests(),notifier.includeCustomMessage()), getBuildColor(r));

    }
}
 
開發者ID:FluffyFairyGames,項目名稱:jenkins-telegram-plugin,代碼行數:29,代碼來源:ActiveNotifier.java


注:本文中的hudson.model.AbstractProject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。