本文整理汇总了Java中hudson.model.queue.QueueTaskFuture类的典型用法代码示例。如果您正苦于以下问题:Java QueueTaskFuture类的具体用法?Java QueueTaskFuture怎么用?Java QueueTaskFuture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueueTaskFuture类属于hudson.model.queue包,在下文中一共展示了QueueTaskFuture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeProject
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
protected void subscribeProject(ProjectFixture fixture) throws Exception {
String name = UUID.randomUUID().toString();
WorkflowJob job = jenkinsRule.getInstance().createProject(WorkflowJob.class, name);
String script = fixture.getPipelineScript().replace("${EmitEvent}", AbstractPipelineIT.class.getName() + ".emitBuildEvent()");
CpsFlowDefinition flowDefinition = new CpsFlowDefinition(script, true);
job.setDefinition(flowDefinition);
QueueTaskFuture<WorkflowRun> run = job.scheduleBuild2(0);
jenkinsRule.assertBuildStatusSuccess(run.get());
resetPipelineBuildEvent(fixture);
if (!fixture.isHasTrigger()) {
return;
}
final String uuid = this.sqsQueue.getUuid();
SQSTrigger trigger = new SQSTrigger(uuid, fixture.isSubscribeInternalScm(), fixture.getScmConfigs());
job.addTrigger(trigger);
trigger.start(job, false);
}
示例2: triggerJob
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
public static QueuedJob triggerJob(BuildContext context, String jobName, Map<String, String> params) throws InterruptedException, ExecutionException {
boolean foundJob = false;
for (AbstractProject proj : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
if (proj.getName().equals(jobName)) {
context.listener.getLogger().println("Triggering build '" + HyperlinkNote.encodeTo("/" + proj.getUrl(), proj.getFullDisplayName()) + "'...");
// add parameters if specified
List<Action> actions = new ArrayList<Action>();
if (params != null) {
List<ParameterValue> paramValues = new ArrayList<ParameterValue>();
for (Map.Entry<String, String> param : params.entrySet()) {
context.listener.getLogger().println(" Adding parameter: '" + param.getKey() + "' = '" + param.getValue() + "'");
paramValues.add(new StringParameterValue(param.getKey(), param.getValue()));
}
actions.add(new ParametersAction(paramValues));
}
QueueTaskFuture scheduled = proj.scheduleBuild2(proj.getQuietPeriod(), new Cause.UpstreamCause((Run<?, ?>) context.build), actions);
return new QueuedJob(proj, scheduled);
}
}
context.listener.fatalError("No project matched job: '" + jobName + "'");
throw new BuildResultException(Result.FAILURE);
}
示例3: testWrapper
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
@Ignore("For local experiments")
@Test
public void testWrapper() throws Exception {
final FreeStyleProject project = jRule.createProject(FreeStyleProject.class, "freestyle");
final DockerConnector connector = new DockerConnector("tcp://" + ADDRESS + ":2376/");
connector.setConnectorType(JERSEY);
final DockerSlaveConfig config = new DockerSlaveConfig();
config.getDockerContainerLifecycle().setImage("java:8-jdk-alpine");
config.setLauncher(new NoOpDelegatingComputerLauncher(new DockerComputerSingleJNLPLauncher()));
config.setRetentionStrategy(new DockerOnceRetentionStrategy(10));
final DockerSimpleBuildWrapper dockerSimpleBuildWrapper = new DockerSimpleBuildWrapper(connector, config);
project.getBuildWrappersList().add(dockerSimpleBuildWrapper);
project.getBuildersList().add(new Shell("sleep 30"));
final QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
jRule.waitUntilNoActivity();
jRule.pause();
}
示例4: setUp
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
@Before
@SuppressWarnings("unused")
public void setUp() throws Exception {
AbstractProject<?, ?> project = jenkinsRule.createFreeStyleProject("GhprcRepoTest");
trigger = spy(GhprcTestUtil.getTrigger(null));
doReturn(mock(QueueTaskFuture.class)).when(trigger).startJob(any(GhprcCause.class), any(GhprcRepository.class));
initGHPRWithTestData();
// Mock github API
given(helper.getGitHub()).willReturn(gitHub);
given(gitHub.get()).willReturn(gt);
given(gt.getRepository(anyString())).willReturn(ghRepository);
// Mock rate limit
given(gt.getRateLimit()).willReturn(ghRateLimit);
increaseRateLimitToDefaults();
addSimpleStatus();
}
示例5: verifyMinimumBuildQueue
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
@Ignore("Unit test fails when performing a release. The queue has a race condition" +
"which is resolved in 1.607+ (TODO).")
@Test
public void verifyMinimumBuildQueue() throws Exception {
// Given
QueueTaskFuture<FreeStyleBuild> build;
String assignedLabel = "foo";
FreeStyleProject p = j.createFreeStyleProject("bar");
p.setAssignedLabel(new LabelAtom(assignedLabel));
BuildQueue queue = new BuildQueue();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// When
build = p.scheduleBuild2(0);
queue.addContents(createContainer(baos));
// Then
build.cancel(true);
List<String> output = new ArrayList<String>(Arrays.asList(baos.toString().split("\n")));
assertContains(output, "1 item");
assertContains(output, p.getDisplayName());
assertContains(output, "Waiting for next available executor");
}
示例6: runWorkflowJob
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
private WorkflowRun runWorkflowJob(WorkflowJob job) throws ExecutionException, InterruptedException {
QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0);
assertThat(runFuture, notNullValue());
run = runFuture.get();
return run;
}
示例7: createWorkflowJobAndRun
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
public static WorkflowRun createWorkflowJobAndRun(Jenkins jenkins, String script) throws Exception {
WorkflowJob job = jenkins.createProject(WorkflowJob.class, RandomStringUtils.randomAlphanumeric(7));
job.setDefinition(new CpsFlowDefinition(script));
QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0);
assertThat(runFuture, notNullValue());
return runFuture.get();
}
示例8: createWorkflowJobAndRun
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
private static WorkflowRun createWorkflowJobAndRun(String script) throws Exception {
WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, RandomStringUtils.randomAlphanumeric(7));
job.setDefinition(new CpsFlowDefinition(script));
QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0);
assertThat(runFuture, notNullValue());
return runFuture.get();
}
示例9: startJob
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
/**
* Invoked when a tag-related event is received.
*
* @param cause build cause
* @return task future, or {@code null} if it could not be scheduled.
*/
public QueueTaskFuture startJob(@Nonnull TagCause cause) {
LOGGER.info(cause.getShortDescription());
ArrayList<ParameterValue> values = getDefaultParameters();
values.add(new StringParameterValue("GH_PUSHER", cause.getPusher()));
values.add(new StringParameterValue("GIT_TAG", cause.getTag()));
values.add(new StringParameterValue("GIT_REF", cause.getRef()));
ParameterizedJobMixIn pjob = asParameterizedJobMixIn(job);
return pjob.scheduleBuild2(3, new CauseAction(cause), new ParametersAction(values));
}
示例10: doBuild
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
@Override
public FormValidation doBuild(StaplerRequest req) throws IOException {
FormValidation result;
try {
Jenkins instance = GitHubWebHook.getJenkinsInstance();
if (!instance.hasPermission(Item.BUILD)) {
return FormValidation.error("Forbidden");
}
final String prNumberParam = "prNumber";
int prId = 0;
if (req.hasParameter(prNumberParam)) {
prId = Integer.valueOf(req.getParameter(prNumberParam));
}
if (prId == 0 || !getPulls().containsKey(prId)) {
return FormValidation.error("No branch to build");
}
final GitHubPRPullRequest localPR = getPulls().get(prId);
final GitHubPRCause cause = new GitHubPRCause(localPR, null, false, "Manual run.");
final JobRunnerForCause runner = new JobRunnerForCause(getJob(), ghPRTriggerFromJob(getJob()));
final QueueTaskFuture<?> queueTaskFuture = runner.startJob(cause);
if (nonNull(queueTaskFuture)) {
result = FormValidation.ok("Build scheduled");
} else {
result = FormValidation.warning("Build not scheduled");
}
} catch (Exception e) {
LOG.error("Can't start build", e.getMessage());
result = FormValidation.error(e, "Can't start build: " + e.getMessage());
}
return result;
}
示例11: rebuild
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
public static boolean rebuild(Run<?, ?> run) {
final QueueTaskFuture queueTaskFuture = asParameterizedJobMixIn(run.getParent())
.scheduleBuild2(
0,
run.getAction(ParametersAction.class),
run.getAction(CauseAction.class),
run.getAction(BuildBadgeAction.class)
);
return queueTaskFuture != null;
}
示例12: doBuild
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
@RequirePOST
public FormValidation doBuild(StaplerRequest req) throws IOException {
FormValidation result;
try {
Jenkins instance = GitHubWebHook.getJenkinsInstance();
if (!instance.hasPermission(Item.BUILD)) {
return FormValidation.error("Forbidden");
}
final String param = "branchName";
String branchName = null;
if (req.hasParameter(param)) {
branchName = req.getParameter(param);
}
if (isNull(branchName) || !getBranches().containsKey(branchName)) {
return FormValidation.error("No branch to build");
}
final GitHubBranch localBranch = getBranches().get(branchName);
final GitHubBranchCause cause = new GitHubBranchCause(localBranch, this, "Manual run.", false);
final JobRunnerForBranchCause runner = new JobRunnerForBranchCause(getJob(),
ghBranchTriggerFromJob(getJob()));
final QueueTaskFuture<?> queueTaskFuture = runner.startJob(cause);
if (nonNull(queueTaskFuture)) {
result = FormValidation.ok("Build scheduled");
} else {
result = FormValidation.warning("Build not scheduled");
}
} catch (Exception e) {
LOG.error("Can't start build", e.getMessage());
result = FormValidation.error(e, "Can't start build: " + e.getMessage());
}
return result;
}
示例13: apply
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
@Override
public boolean apply(GitHubBranchCause cause) {
try {
cause.setPollingLogFile(trigger.getPollingLogAction().getPollingLogFile());
StringBuilder sb = new StringBuilder();
sb.append("Jenkins queued the run (").append(cause.getReason()).append(")");
if (trigger.isCancelQueued() && cancelQueuedBuildByBranchName(cause.getBranchName())) {
sb.append(". Queued builds aborted");
}
QueueTaskFuture<?> queueTaskFuture = startJob(cause);
if (isNull(queueTaskFuture)) {
LOGGER.error("{} job didn't start", job.getFullName());
}
LOGGER.info(sb.toString());
// remote connection
if (trigger.isPreStatus()) {
trigger.getRemoteRepository()
.createCommitStatus(cause.getCommitSha(),
GHCommitState.PENDING,
null,
sb.toString(),
job.getFullName());
}
} catch (IOException e) {
LOGGER.error("Can't trigger build ({})", e.getMessage(), e);
return false;
}
return true;
}
示例14: schedule
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
public static QueueTaskFuture schedule(Job<?, ?> job, int number, String param, int queuetPeriod) {
ParameterizedJobMixIn jobMixIn = JobInfoHelpers.asParameterizedJobMixIn(job);
GitHubPRCause cause = newGitHubPRCause().withNumber(number);
ParametersAction parametersAction = new ParametersAction(
Collections.<ParameterValue>singletonList(new StringParameterValue("value", param))
);
return jobMixIn.scheduleBuild2(queuetPeriod, new CauseAction(cause), parametersAction);
}
示例15: startJob
import hudson.model.queue.QueueTaskFuture; //导入依赖的package包/类
public QueueTaskFuture<?> startJob(GhprcCause cause, GhprcRepository repo) {
ArrayList<ParameterValue> values = getDefaultParameters();
final String commitSha = cause.isMerged() ? "origin/pr/" + cause.getPullID() + "/merge" : cause.getCommit();
values.add(new StringParameterValue("sha1", commitSha));
values.add(new StringParameterValue("ghprcActualCommit", cause.getCommit()));
setCommitAuthor(cause, values);
final StringParameterValue pullIdPv = new StringParameterValue("ghprcPullId", String.valueOf(cause.getPullID()));
values.add(pullIdPv);
values.add(new StringParameterValue("ghprcTargetBranch", String.valueOf(cause.getTargetBranch())));
values.add(new StringParameterValue("ghprcSourceBranch", String.valueOf(cause.getSourceBranch())));
values.add(new StringParameterValue("GIT_BRANCH", String.valueOf(cause.getSourceBranch())));
// it's possible the GHUser doesn't have an associated email address
values.add(new StringParameterValue("ghprcPullAuthorEmail", getString(cause.getAuthorEmail(), "")));
values.add(new StringParameterValue("ghprcPullDescription", String.valueOf(cause.getShortDescription())));
values.add(new StringParameterValue("ghprcPullTitle", String.valueOf(cause.getTitle())));
values.add(new StringParameterValue("ghprcPullLink", String.valueOf(cause.getUrl())));
values.add(new StringParameterValue("ghprcOutputFile", getDescriptor().getOutputFile()));
try {
values.add(new StringParameterValue("ghprcTargetCommit",
repo.getGitHubRepo().getBranches().get(cause.getTargetBranch()).getSHA1()));
} catch (IOException e) {
logger.log(Level.SEVERE, "Unable to get branches from github repo", e);
}
// add the previous pr BuildData as an action so that the correct change log is generated by the GitSCM plugin
// note that this will be removed from the Actions list after the job is completed so that the old (and incorrect)
// one isn't there
return this.job.scheduleBuild2(job.getQuietPeriod(), cause, new ParametersAction(values), findPreviousBuildForPullId(pullIdPv));
}