本文整理汇总了Java中hudson.model.queue.QueueTaskFuture.get方法的典型用法代码示例。如果您正苦于以下问题:Java QueueTaskFuture.get方法的具体用法?Java QueueTaskFuture.get怎么用?Java QueueTaskFuture.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.model.queue.QueueTaskFuture
的用法示例。
在下文中一共展示了QueueTaskFuture.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: 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();
}
示例4: redirectToBuildUrl
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void redirectToBuildUrl() throws IOException, ExecutionException, InterruptedException, TimeoutException {
FreeStyleProject testProject = jenkins.createFreeStyleProject();
testProject.setScm(new GitSCM(gitRepoUrl));
testProject.setQuietPeriod(0);
QueueTaskFuture<FreeStyleBuild> future = testProject.scheduleBuild2(0);
FreeStyleBuild build = future.get(15, TimeUnit.SECONDS);
getBuildPageRedirectAction(testProject).execute(response);
verify(response).sendRedirect2(jenkins.getInstance().getRootUrl() + build.getUrl());
}
示例5: redirectToBuildStatusUrl
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void redirectToBuildStatusUrl() throws IOException, ExecutionException, InterruptedException, TimeoutException {
FreeStyleProject testProject = jenkins.createFreeStyleProject();
testProject.setScm(new GitSCM(gitRepoUrl));
testProject.setQuietPeriod(0);
QueueTaskFuture<FreeStyleBuild> future = testProject.scheduleBuild2(0);
FreeStyleBuild build = future.get(5, TimeUnit.SECONDS);
doThrow(IOException.class).when(response).sendRedirect2(jenkins.getInstance().getRootUrl() + build.getUrl());
getBuildPageRedirectAction(testProject).execute(response);
verify(response).sendRedirect2(jenkins.getInstance().getRootUrl() + build.getBuildStatusUrl());
}
示例6: build_alreadyBuiltMR_alreadyBuiltMR
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void build_alreadyBuiltMR_alreadyBuiltMR() throws IOException, ExecutionException, InterruptedException {
FreeStyleProject testProject = jenkins.createFreeStyleProject();
testProject.addTrigger(trigger);
testProject.setScm(new GitSCM(gitRepoUrl));
QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new ParametersAction(new StringParameterValue("gitlabTargetBranch", "master")));
future.get();
exception.expect(HttpResponses.HttpResponseException.class);
new NoteBuildAction(testProject, getJson("NoteEvent_alreadyBuiltMR.json"), null).execute(response);
verify(trigger).onPost(any(NoteHook.class));
}
示例7: build_alreadyBuiltMR_differentTargetBranch
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void build_alreadyBuiltMR_differentTargetBranch() throws IOException, ExecutionException, InterruptedException {
FreeStyleProject testProject = jenkins.createFreeStyleProject();
testProject.addTrigger(trigger);
testProject.setScm(new GitSCM(gitRepoUrl));
QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new GitLabWebHookCause(causeData()
.withActionType(CauseData.ActionType.NOTE)
.withSourceProjectId(1)
.withTargetProjectId(1)
.withBranch("feature")
.withSourceBranch("feature")
.withUserName("")
.withSourceRepoHomepage("https://gitlab.org/test")
.withSourceRepoName("test")
.withSourceNamespace("test-namespace")
.withSourceRepoUrl("[email protected]:test.git")
.withSourceRepoSshUrl("[email protected]:test.git")
.withSourceRepoHttpUrl("https://gitlab.org/test.git")
.withMergeRequestTitle("Test")
.withMergeRequestId(1)
.withMergeRequestIid(1)
.withTargetBranch("master")
.withTargetRepoName("test")
.withTargetNamespace("test-namespace")
.withTargetRepoSshUrl("[email protected]:test.git")
.withTargetRepoHttpUrl("https://gitlab.org/test.git")
.withTriggeredByUser("test")
.withLastCommit("123")
.withTargetProjectUrl("https://gitlab.org/test")
.build()));
future.get();
exception.expect(HttpResponses.HttpResponseException.class);
new NoteBuildAction(testProject, getJson("NoteEvent_alreadyBuiltMR.json"), null).execute(response);
verify(trigger).onPost(any(NoteHook.class));
}
示例8: skip_alreadyBuiltMR
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void skip_alreadyBuiltMR() throws IOException, ExecutionException, InterruptedException {
FreeStyleProject testProject = jenkins.createFreeStyleProject();
testProject.addTrigger(trigger);
testProject.setScm(new GitSCM(gitRepoUrl));
QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new ParametersAction(new StringParameterValue("gitlabTargetBranch", "master")));
future.get();
exception.expect(HttpResponses.HttpResponseException.class);
new MergeRequestBuildAction(testProject, getJson("MergeRequestEvent_alreadyBuiltMR.json"), null).execute(response);
verify(trigger, never()).onPost(any(MergeRequestHook.class));
}
示例9: build_alreadyBuiltMR_differentTargetBranch
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void build_alreadyBuiltMR_differentTargetBranch() throws IOException, ExecutionException, InterruptedException {
FreeStyleProject testProject = jenkins.createFreeStyleProject();
testProject.addTrigger(trigger);
testProject.setScm(new GitSCM(gitRepoUrl));
QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new GitLabWebHookCause(causeData()
.withActionType(CauseData.ActionType.MERGE)
.withSourceProjectId(1)
.withTargetProjectId(1)
.withBranch("feature")
.withSourceBranch("feature")
.withUserName("")
.withSourceRepoHomepage("https://gitlab.org/test")
.withSourceRepoName("test")
.withSourceNamespace("test-namespace")
.withSourceRepoUrl("[email protected]:test.git")
.withSourceRepoSshUrl("[email protected]:test.git")
.withSourceRepoHttpUrl("https://gitlab.org/test.git")
.withMergeRequestTitle("Test")
.withMergeRequestId(1)
.withMergeRequestIid(1)
.withTargetBranch("master")
.withTargetRepoName("test")
.withTargetNamespace("test-namespace")
.withTargetRepoSshUrl("[email protected]:test.git")
.withTargetRepoHttpUrl("https://gitlab.org/test.git")
.withTriggeredByUser("test")
.withLastCommit("123")
.withTargetProjectUrl("https://gitlab.org/test")
.build()));
future.get();
exception.expect(HttpResponses.HttpResponseException.class);
new MergeRequestBuildAction(testProject, getJson("MergeRequestEvent_alreadyBuiltMR.json"), null).execute(response);
verify(trigger).onPost(any(MergeRequestHook.class));
}
示例10: buildTwoandCheckOrder
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
/**
* @param sleep
* @param eps
* @param parallel
* @param p
*/
private void buildTwoandCheckOrder(long sleep, double eps, boolean parallel, InheritanceProject p) {
try {
/* Scheduling the builds.
* We need to give the gpp a random parameter, to avoid Jenkins
* from mercilessly killing our duplicated jobs, if two of them
* happen to be simultaneously in the queue.
*/
QueueTaskFuture<InheritanceBuild> f1 = p.scheduleBuild2(
0, new UserIdCause(),
new ParametersAction(
new StringParameterValue("RNG", UUID.randomUUID().toString())
)
);
QueueTaskFuture<InheritanceBuild> f2 = p.scheduleBuild2(
0, new UserIdCause(),
new ParametersAction(
new StringParameterValue("RNG", UUID.randomUUID().toString())
)
);
assertNotNull("First build failed to start, miserably", f1);
assertNotNull("Second build failed to start, miserably", f2);
InheritanceBuild[] builds = { f1.get(), f2.get() };
assertNotNull("First build failed to evaluate", builds[0]);
assertNotNull("Second build failed to evaluate", builds[1]);
checkBuildOrder((long)eps*sleep, parallel, builds);
} catch (Exception ex) {
fail(ex.getMessage());
}
}
示例11: testDockerShellStep
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void testDockerShellStep() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
// String dockerfilePath = dumbSlave.getChannel().call(new DockerBuildImageStepTest.StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerShellStep dockerShellStep = new DockerShellStep();
dockerShellStep.setShellScript("env && pwd");
dockerShellStep.setConnector(dockerConnector);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerShellStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例12: testComboBuild
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Ignore
@Test
public void testComboBuild() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
String dockerfilePath = dumbSlave.getChannel().call(new StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerBuildImage buildImage = new DockerBuildImage();
buildImage.setBaseDirectory(dockerfilePath);
buildImage.setPull(true);
buildImage.setTags(Collections.singletonList("localhost:5000/myfirstimage"));
DockerImageComboStep comboStep = new DockerImageComboStep(dockerConnector, buildImage);
comboStep.setClean(true);
comboStep.setPush(true);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(comboStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例13: testBuild
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@Test
public void testBuild() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
String dockerfilePath = dumbSlave.getChannel().call(new StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerBuildImage buildImage = new DockerBuildImage();
buildImage.setBaseDirectory(dockerfilePath);
buildImage.setPull(true);
DockerBuildImageStep dockerBuildImageStep = new DockerBuildImageStep(dockerConnector, buildImage);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerBuildImageStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例14: deploy
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
@JavaScriptMethod
public String deploy(String version, String environment) {
LOGGER.info("Deploy version " + version + " to environment " + environment);
// Get the environment with corresponding build-job
Environment buildEnvironment = null;
for (Environment env : environments) {
if (env.getAwsInstance().equals(environment)) {
buildEnvironment = env;
break;
}
}
final AbstractProject buildJob = Jenkins.getInstance().getItemByFullName(buildEnvironment.getBuildJob(), AbstractProject.class);
LOGGER.info("Executing job: " + buildJob);
if (buildJob == null) {
return String.format(Messages.DashboardView_buildJobNotFound(), buildEnvironment.getName());
}
if ((!buildJob.isBuildable()) || (!buildJob.isParameterized())) {
return Messages.DashboardView_deploymentCannotBeExecuted();
}
final ParametersAction versionParam = new ParametersAction(new StringParameterValue(PARAM_VERSION, version));
final ParametersAction environmentParam = new ParametersAction(new StringParameterValue(PARAM_ENVIRONMENT, environment));
final ParametersAction ec2RegionParam = new ParametersAction(new StringParameterValue(PARAM_EC2_REGION, environment));
final ParametersAction awsKeyParam = new ParametersAction(new StringParameterValue(PARAM_AWS_KEY, environment));
List<ParametersAction> actions = Arrays.asList(versionParam, environmentParam, ec2RegionParam, awsKeyParam);
QueueTaskFuture<AbstractBuild> scheduledBuild = buildJob.scheduleBuild2(2, new Cause.UserIdCause(), actions);
Result result = Result.FAILURE;
try {
AbstractBuild finishedBuild = scheduledBuild.get();
result = finishedBuild.getResult();
LOGGER.info("Build finished with result: " + result + " completed in: " + finishedBuild.getDurationString() + ". ");
} catch (Exception e) {
LOGGER.severe("Error while waiting for build " + scheduledBuild.toString() + ".");
LOGGER.severe(e.getMessage());
LOGGER.severe(ExceptionUtils.getFullStackTrace(e));
return String.format(Messages.DashboardView_buildJobFailed(), buildJob.getName());
}
if (result == Result.SUCCESS) {
return String.format(Messages.DashboardView_buildJobScheduledSuccessfully(), buildJob.getName());
}
return String.format(Messages.DashboardView_buildJobSchedulingFailed(), buildJob.getName());
}
示例15: testSaveParameters
import hudson.model.queue.QueueTaskFuture; //导入方法依赖的package包/类
/**
* Test persisting jobs with parameters.
*
* @throws Exception in Jenkins rule
*/
@Test
public void testSaveParameters() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
GroovyScript scriptParam001 = new GroovyScript(new SecureGroovyScript(SCRIPT_PARAM001, false, null),
new SecureGroovyScript(SCRIPT_FALLBACK_PARAM001, false, null));
ChoiceParameter param001 = new ChoiceParameter("param001", "param001 description", "random-name",
scriptParam001, AbstractUnoChoiceParameter.PARAMETER_TYPE_SINGLE_SELECT, true, 1);
GroovyScript scriptParam002 = new GroovyScript(new SecureGroovyScript(SCRIPT_PARAM002, false, null),
new SecureGroovyScript(SCRIPT_FALLBACK_PARAM002, false, null));
CascadeChoiceParameter param002 = new CascadeChoiceParameter("param002", "param002 description", "random-name",
scriptParam002, AbstractUnoChoiceParameter.PARAMETER_TYPE_SINGLE_SELECT, "param001", true, 1);
ParametersDefinitionProperty param001Def = new ParametersDefinitionProperty(
Arrays.<ParameterDefinition>asList(param001, param002));
project.addProperty(param001Def);
QueueTaskFuture<FreeStyleBuild> future = project.scheduleBuild2(0);
FreeStyleBuild build = future.get();
// even though the cascaded parameter will fail to evaluate, we should
// still get a success here.
assertEquals(Result.SUCCESS, build.getResult());
XmlFile configXml = project.getConfigFile();
FreeStyleProject reReadProject = (FreeStyleProject) configXml.read();
int found = 0;
for (Entry<JobPropertyDescriptor, JobProperty<? super FreeStyleProject>> entry : reReadProject.getProperties()
.entrySet()) {
JobProperty<? super FreeStyleProject> jobProperty = entry.getValue();
if (jobProperty instanceof ParametersDefinitionProperty) {
ParametersDefinitionProperty paramDef = (ParametersDefinitionProperty) jobProperty;
List<ParameterDefinition> parameters = paramDef.getParameterDefinitions();
for (ParameterDefinition parameter : parameters) {
if (parameter instanceof AbstractScriptableParameter) {
found++;
AbstractScriptableParameter choiceParam = (AbstractScriptableParameter) parameter;
String scriptText = ((GroovyScript) choiceParam.getScript()).getScript().getScript();
String fallbackScriptText = ((GroovyScript) choiceParam.getScript()).getFallbackScript()
.getScript();
assertTrue("Found an empty script!", StringUtils.isNotBlank(scriptText));
assertTrue("Found an empty fallback script!", StringUtils.isNotBlank(fallbackScriptText));
if (parameter.getName().equals("param001")) {
assertEquals(SCRIPT_PARAM001, scriptText);
assertEquals(SCRIPT_FALLBACK_PARAM001, fallbackScriptText);
} else {
assertEquals(SCRIPT_PARAM002, scriptText);
assertEquals(SCRIPT_FALLBACK_PARAM002, fallbackScriptText);
}
}
}
}
}
// We have two parameters before saving. We must have two now.
assertEquals("Didn't find all parameters after persisting xml", 2, found);
}