当前位置: 首页>>代码示例>>Java>>正文


Java Job类代码示例

本文整理汇总了Java中hudson.model.Job的典型用法代码示例。如果您正苦于以下问题:Java Job类的具体用法?Java Job怎么用?Java Job使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Job类属于hudson.model包,在下文中一共展示了Job类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultParametersValues

import hudson.model.Job; //导入依赖的package包/类
/**
 * @see jenkins.model.ParameterizedJobMixIn#getDefaultParametersValues()
 */
public static List<ParameterValue> getDefaultParametersValues(Job<?, ?> job) {
    ParametersDefinitionProperty paramDefProp = job.getProperty(ParametersDefinitionProperty.class);
    List<ParameterValue> defValues = new ArrayList<>();

    /*
    * This check is made ONLY if someone will call this method even if isParametrized() is false.
    */
    if (paramDefProp == null) {
        return defValues;
    }

    /* Scan for all parameter with an associated default values */
    for (ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) {
        ParameterValue defaultValue = paramDefinition.getDefaultParameterValue();

        if (defaultValue != null) {
            defValues.add(defaultValue);
        }
    }

    return defValues;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:26,代码来源:JobHelper.java

示例2: getLastRed

import hudson.model.Job; //导入依赖的package包/类
private RedInterval getLastRed(Job job, Run lastUnsuccessfulBuild) {
    Run repair = lastUnsuccessfulBuild.getNextBuild();
    Run initialFailure;
    Run previousSuccessfulBuild = lastUnsuccessfulBuild.getPreviousSuccessfulBuild();
    if (previousSuccessfulBuild == null) {
        // never succeeded, get the first build
        initialFailure = lastUnsuccessfulBuild;
        while (initialFailure.getPreviousBuild() != null) {
            initialFailure = initialFailure.getPreviousBuild();
        }
    } else {
        initialFailure = previousSuccessfulBuild.getNextBuild();
    }

    return new RedInterval(job, repair, initialFailure);
}
 
开发者ID:oliveiragabriel07,项目名称:redtime,代码行数:17,代码来源:RedtimeReportPortlet.java

示例3: getCollaborators

import hudson.model.Job; //导入依赖的package包/类
public static List<String> getCollaborators(@Nonnull final Job<?,?> job) {
    ExtendedGitHubClient client = getGitHubClient(job);
    RepositoryId repository = getRepositoryId(job);
    CollaboratorService collaboratorService = new CollaboratorService(client);

    try {
        return collaboratorService.getCollaborators(repository)
                .stream()
                .map(User::getLogin)
                .collect(Collectors.toList());
    } catch (final IOException e) {
        LOG.debug("Received an exception while trying to retrieve the collaborators for the repository: {}",
                repository, e);
        return Collections.emptyList();
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:17,代码来源:GitHubHelper.java

示例4: PullRequestGroovyObject

import hudson.model.Job; //导入依赖的package包/类
public PullRequestGroovyObject(@Nonnull final CpsScript script) throws Exception {
    this.script = script;
    Run<?, ?> build = script.$build();
    if (build == null) {
        throw new IllegalStateException("No associated build");
    }
    Job job = build.getParent();

    this.pullRequestHead = GitHubHelper.getPullRequest(job);

    this.base = GitHubHelper.getRepositoryId(job);
    this.head = RepositoryId.create(pullRequestHead.getSourceOwner(), pullRequestHead.getSourceRepo());

    this.gitHubClient = GitHubHelper.getGitHubClient(job);
    this.pullRequestService = new ExtendedPullRequestService(gitHubClient);
    this.issueService = new ExtendedIssueService(gitHubClient);
    this.commitService = new ExtendedCommitService(gitHubClient);
    this.pullRequest = pullRequestService.getPullRequest(base, pullRequestHead.getNumber());
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:20,代码来源:PullRequestGroovyObject.java

示例5: getPollingEnvVars

import hudson.model.Job; //导入依赖的package包/类
@Nonnull
public static Map<String, String> getPollingEnvVars(@Nonnull Job<?, ?> job, @CheckForNull Node node) throws EnvInjectException {

    final Run<?, ?> lastBuild = job.getLastBuild();
    if (lastBuild != null) {
        if (EnvInjectPluginHelper.isEnvInjectPluginInstalled()) {
            return getEnVars(lastBuild);
        }
    }

    if (node == null) {
        return getFallBackMasterNode(job);
    }
    if (node.getRootPath() == null) {
        return getFallBackMasterNode(job);
    }

    return getDefaultEnvVarsJob(job, node);
}
 
开发者ID:jenkinsci,项目名称:envinject-api-plugin,代码行数:20,代码来源:EnvVarsResolver.java

示例6: gatherEnvVarsMaster

import hudson.model.Job; //导入依赖的package包/类
@Nonnull
private static Map<String, String> gatherEnvVarsMaster(@Nonnull Job<?, ?> job) throws EnvInjectException {
    final Jenkins jenkins;
    try {
        jenkins = Jenkins.getActiveInstance();
    } catch(IllegalStateException ex) {
        throw new EnvInjectException(ex);
    }
    
    EnvVars env = new EnvVars();
    env.put("JENKINS_SERVER_COOKIE", Util.getDigestOf("ServerID:" + jenkins.getSecretKey()));
    env.put("HUDSON_SERVER_COOKIE", Util.getDigestOf("ServerID:" + jenkins.getSecretKey())); // Legacy compatibility
    env.put("JOB_NAME", job.getFullName());
    
    env.put("JENKINS_HOME", jenkins.getRootDir().getPath());
    env.put("HUDSON_HOME", jenkins.getRootDir().getPath());   // legacy compatibility

    String rootUrl = jenkins.getRootUrl();
    if (rootUrl != null) {
        env.put("JENKINS_URL", rootUrl);
        env.put("HUDSON_URL", rootUrl); // Legacy compatibility
        env.put("JOB_URL", rootUrl + job.getUrl());
    }

    return env;
}
 
开发者ID:jenkinsci,项目名称:envinject-api-plugin,代码行数:27,代码来源:EnvVarsResolver.java

示例7: start

import hudson.model.Job; //导入依赖的package包/类
@Override
public void start(@Nonnull final Job<?, ?> job, final boolean newInstance) {
    super.start(job, newInstance);

    loadSqsJob();

    final DescriptorImpl descriptor = (DescriptorImpl) this.getDescriptor();
    descriptor.queue.execute(new Runnable() {

        @Override
        public void run() {
            boolean succeed = SQSTrigger.this.scheduler.register(SQSTrigger.this);
            log.debug("Register trigger for %s? %s", SQSTrigger.this.job, SQSTrigger.this.getQueueUuid(), succeed);
        }
    });
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:17,代码来源:SQSTrigger.java

示例8: onChange

import hudson.model.Job; //导入依赖的package包/类
@Override
public void onChange(Saveable o, XmlFile file) {

    LOG.fine(">>> MirrorGateSaveableListener onChange starts");

    if (o instanceof Job) {
        Job job = (Job) o;
        if (!job.isBuildable()) {
            helper.sendBuildFromJob(job);
        }
    }

    super.onChange(o, file);

    LOG.fine(">>> MirrorGateSaveableListener onChange ends");
}
 
开发者ID:BBVA,项目名称:mirrorgate-jenkins-builds-collector,代码行数:17,代码来源:MirrorGateSaveableListener.java

示例9: doTestIcon

import hudson.model.Job; //导入依赖的package包/类
/**
    * Serves the testCoverage badge image. TO DO
    * @param req
    * @param rsp
    * @param job
    * @return
    */
   @SuppressWarnings("rawtypes")
public HttpResponse doTestIcon(StaplerRequest req, StaplerResponse rsp, @QueryParameter String job) {
       Job<?, ?> project = getProject(job);
       Integer testPass = null;
       Integer testTotal = null;

       if (project.getLastCompletedBuild() != null) {
       	AbstractTestResultAction testAction =  project.getLastCompletedBuild().getAction(AbstractTestResultAction.class);
		if(testAction != null){
			int total = testAction.getTotalCount();
			int pass = total - testAction.getFailCount() - testAction.getSkipCount();
			
			testTotal = total;
			testPass = pass;
		}
       }
       return iconResolver.getTestResultImage(testPass, testTotal);
   }
 
开发者ID:SxMShaDoW,项目名称:embeddable-badges-plugin,代码行数:26,代码来源:PublicBadgeAction.java

示例10: doBuildDescriptionIcon

import hudson.model.Job; //导入依赖的package包/类
/**
 * Serves the Build Description badge image.
 * @param req
 * @param rsp
 * @param job
 * @return
 */
public HttpResponse doBuildDescriptionIcon(StaplerRequest req, StaplerResponse rsp, @QueryParameter String job) {
    Job<?, ?> project = getProject(job);
    String buildDescription = null;
    
    /*if (project.getLastSuccessfulBuild() != null) {
        buildDescription = project.getLastSuccessfulBuild().getDescription();
    }*/
    
    /*if (project.getLastBuild() != null) {
        buildDescription = project.getLastBuild().getDescription();
    }*/
    
    if (project.getLastCompletedBuild() != null) {
        buildDescription = project.getLastCompletedBuild().getDescription();
    }
    
    return iconResolver.getBuildDescriptionImage(buildDescription);
}
 
开发者ID:SxMShaDoW,项目名称:embeddable-badges-plugin,代码行数:26,代码来源:PublicBadgeAction.java

示例11: getProject

import hudson.model.Job; //导入依赖的package包/类
/** 
 * TO DO
 * @param job
 * @return
 */
private Job<?, ?> getProject(String job) {
    Job<?, ?> p;

    // as the user might have ViewStatus permission only (e.g. as anonymous)
    // we get get the project impersonate and 
    // check for permission after getting the project
    SecurityContext orig = impersonate(SYSTEM);
    try {
        p = getInstance().getItemByFullName(job, Job.class);
    } finally {
        setContext(orig);
    }

    // check if user has permission to view the status
    if (p == null || !(p.hasPermission(VIEW_STATUS))) {
        throw notFound();
    }

    return p;
}
 
开发者ID:SxMShaDoW,项目名称:embeddable-badges-plugin,代码行数:26,代码来源:PublicBadgeAction.java

示例12: getBuild

import hudson.model.Job; //导入依赖的package包/类
@Override
@CheckForNull
public Run<?, ?> getBuild(@Nonnull Job<?, ?> job, @Nonnull RunSelectorContext context) {
    String resolvedId = context.getEnvVars().expand(id);
    if (resolvedId.startsWith("$")) {
        context.logDebug("Unresolved variable {0}", resolvedId);
        return null;
    }

    Permalink p = job.getPermalinks().get(resolvedId);
    if (p == null) {
        context.logDebug("No permalink found for {0}", resolvedId);
        return null;
    }

    Run<?, ?> run = p.resolve(job);
    if (run == null) {
        context.logDebug("No such build {0} in {1}", id, job.getFullName());
        return null;
    }

    return run;
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:24,代码来源:PermalinkRunSelector.java

示例13: getBuild

import hudson.model.Job; //导入依赖的package包/类
@Override
@CheckForNull
public Run<?, ?> getBuild(@Nonnull Job<?, ?> job, @Nonnull RunSelectorContext context) throws IOException {
    String resolvedBuildNumber = context.getEnvVars().expand(buildNumber);
    if (resolvedBuildNumber.startsWith("$")) {
        context.logDebug("Unresolved variable {0}", resolvedBuildNumber);
        return null;
    }

    Run<?, ?> run;
    try {
        run = job.getBuildByNumber(Integer.parseInt(resolvedBuildNumber));
    } catch (NumberFormatException e) {
        throw new AbortException(Messages.BuildNumberRunSelector_NotANumber(resolvedBuildNumber));
    }

    if (run == null) {
        context.logDebug("No such build {0} in {1}", buildNumber, job.getFullName());
        return null;
    }

    return run;
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:24,代码来源:BuildNumberRunSelector.java

示例14: perform

import hudson.model.Job; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
        throws InterruptedException, IOException {
    for (Cause.UpstreamCause c: Util.filter(build.getCauses(), Cause.UpstreamCause.class)) {
        Job<?,?> upstreamProject = Jenkins.getInstance().getItemByFullName(c.getUpstreamProject(), Job.class);
        if (upstreamProject == null) {
            listener.getLogger().println(String.format("Not Found: %s", c.getUpstreamProject()));
            continue;
        }
        
        Run<?,?> upstreamBuild = upstreamProject.getBuildByNumber(c.getUpstreamBuild());
        if (upstreamBuild == null) {
            listener.getLogger().println(String.format("Not Found: %s - %d", upstreamProject.getFullName(), c.getUpstreamBuild()));
            continue;
        }
        
        listener.getLogger().println(String.format("Removed: %s - %s", upstreamProject.getFullName(), upstreamBuild.getFullDisplayName()));
        upstreamBuild.delete();
    }
    return true;
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:22,代码来源:RemoveUpstreamBuilder.java

示例15: before

import hudson.model.Job; //导入依赖的package包/类
@Before
public void before() {
    build = Mockito.mock(Run.class);
    Job job = Mockito.mock(Job.class);
    measurementRenderer = new ProjectNameRenderer(CUSTOM_PREFIX);
    PerfPublisherBuildAction buildAction = Mockito.mock(PerfPublisherBuildAction.class);
    reports = new ReportContainer();

    Mockito.when(build.getNumber()).thenReturn(BUILD_NUMBER);
    Mockito.when(build.getParent()).thenReturn(job);
    Mockito.when(job.getName()).thenReturn(JOB_NAME);
    Mockito.when(build.getAction(PerfPublisherBuildAction.class)).thenReturn(buildAction);

    Mockito.when(buildAction.getReport()).thenAnswer(new Answer<Report>() {
        @Override
        public Report answer(InvocationOnMock invocationOnMock) {
            return reports.getReports().isEmpty() ? null : reports.getReports().get(0);
        }
    });
    Mockito.when(buildAction.getReports()).thenReturn(reports);
}
 
开发者ID:jenkinsci,项目名称:influxdb-plugin,代码行数:22,代码来源:PerfPublisherPointGeneratorTest.java


注:本文中的hudson.model.Job类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。