本文整理汇总了Java中org.jenkinsci.plugins.workflow.job.WorkflowJob.addTrigger方法的典型用法代码示例。如果您正苦于以下问题:Java WorkflowJob.addTrigger方法的具体用法?Java WorkflowJob.addTrigger怎么用?Java WorkflowJob.addTrigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jenkinsci.plugins.workflow.job.WorkflowJob
的用法示例。
在下文中一共展示了WorkflowJob.addTrigger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeProject
import org.jenkinsci.plugins.workflow.job.WorkflowJob; //导入方法依赖的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: verify_downstream_simple_pipeline_trigger
import org.jenkinsci.plugins.workflow.job.WorkflowJob; //导入方法依赖的package包/类
/**
* The maven-war-app has a dependency on the maven-jar-app
*/
@Test
public void verify_downstream_simple_pipeline_trigger() throws Exception {
System.out.println("gitRepoRule: " + gitRepoRule);
loadMavenJarProjectInGitRepo(this.gitRepoRule);
System.out.println("downstreamArtifactRepoRule: " + downstreamArtifactRepoRule);
loadMavenWarProjectInGitRepo(this.downstreamArtifactRepoRule);
String mavenJarPipelineScript = "node('master') {\n" +
" git($/" + gitRepoRule.toString() + "/$)\n" +
" withMaven() {\n" +
" sh 'mvn install'\n" +
" }\n" +
"}";
String mavenWarPipelineScript = "node('master') {\n" +
" git($/" + downstreamArtifactRepoRule.toString() + "/$)\n" +
" withMaven() {\n" +
" sh 'mvn install'\n" +
" }\n" +
"}";
WorkflowJob mavenJarPipeline = jenkinsRule.createProject(WorkflowJob.class, "build-maven-jar");
mavenJarPipeline.setDefinition(new CpsFlowDefinition(mavenJarPipelineScript, true));
mavenJarPipeline.addTrigger(new WorkflowJobDependencyTrigger());
WorkflowRun mavenJarPipelineFirstRun = jenkinsRule.assertBuildStatus(Result.SUCCESS, mavenJarPipeline.scheduleBuild2(0));
// TODO check in DB that the generated artifact is recorded
WorkflowJob mavenWarPipeline = jenkinsRule.createProject(WorkflowJob.class, "build-maven-war");
mavenWarPipeline.setDefinition(new CpsFlowDefinition(mavenWarPipelineScript, true));
mavenWarPipeline.addTrigger(new WorkflowJobDependencyTrigger());
WorkflowRun mavenWarPipelineFirstRun = jenkinsRule.assertBuildStatus(Result.SUCCESS, mavenWarPipeline.scheduleBuild2(0));
// TODO check in DB that the dependency on the war project is recorded
System.out.println("mavenWarPipelineFirstRun: " + mavenWarPipelineFirstRun);
WorkflowRun mavenJarPipelineSecondRun = jenkinsRule.assertBuildStatus(Result.SUCCESS, mavenJarPipeline.scheduleBuild2(0));
jenkinsRule.waitUntilNoActivity();
WorkflowRun mavenWarPipelineLastRun = mavenWarPipeline.getLastBuild();
System.out.println("mavenWarPipelineLastBuild: " + mavenWarPipelineLastRun + " caused by " + mavenWarPipelineLastRun.getCauses());
assertThat(mavenWarPipelineLastRun.getNumber(), is(mavenWarPipelineFirstRun.getNumber() + 1));
Cause.UpstreamCause upstreamCause = mavenWarPipelineLastRun.getCause(Cause.UpstreamCause.class);
assertThat(upstreamCause, notNullValue());
}
示例3: verify_downstream_pipeline_triggered_on_parent_pom_build
import org.jenkinsci.plugins.workflow.job.WorkflowJob; //导入方法依赖的package包/类
/**
* The maven-war-app has a dependency on the maven-jar-app
*/
@Test
public void verify_downstream_pipeline_triggered_on_parent_pom_build() throws Exception {
System.out.println("gitRepoRule: " + gitRepoRule);
loadMavenJarProjectInGitRepo(this.gitRepoRule);
System.out.println("downstreamArtifactRepoRule: " + downstreamArtifactRepoRule);
loadMavenWarProjectInGitRepo(this.downstreamArtifactRepoRule);
String mavenJarPipelineScript = "node('master') {\n" +
" git($/" + gitRepoRule.toString() + "/$)\n" +
" withMaven() {\n" +
" sh 'mvn install'\n" +
" }\n" +
"}";
String mavenWarPipelineScript = "node('master') {\n" +
" git($/" + downstreamArtifactRepoRule.toString() + "/$)\n" +
" withMaven() {\n" +
" sh 'mvn install'\n" +
" }\n" +
"}";
WorkflowJob mavenJarPipeline = jenkinsRule.createProject(WorkflowJob.class, "build-maven-jar");
mavenJarPipeline.setDefinition(new CpsFlowDefinition(mavenJarPipelineScript, true));
mavenJarPipeline.addTrigger(new WorkflowJobDependencyTrigger());
WorkflowRun mavenJarPipelineFirstRun = jenkinsRule.assertBuildStatus(Result.SUCCESS, mavenJarPipeline.scheduleBuild2(0));
// TODO check in DB that the generated artifact is recorded
WorkflowJob mavenWarPipeline = jenkinsRule.createProject(WorkflowJob.class, "build-maven-war");
mavenWarPipeline.setDefinition(new CpsFlowDefinition(mavenWarPipelineScript, true));
mavenWarPipeline.addTrigger(new WorkflowJobDependencyTrigger());
WorkflowRun mavenWarPipelineFirstRun = jenkinsRule.assertBuildStatus(Result.SUCCESS, mavenWarPipeline.scheduleBuild2(0));
// TODO check in DB that the dependency on the war project is recorded
System.out.println("mavenWarPipelineFirstRun: " + mavenWarPipelineFirstRun);
WorkflowRun mavenJarPipelineSecondRun = jenkinsRule.assertBuildStatus(Result.SUCCESS, mavenJarPipeline.scheduleBuild2(0));
jenkinsRule.waitUntilNoActivity();
WorkflowRun mavenWarPipelineLastRun = mavenWarPipeline.getLastBuild();
System.out.println("mavenWarPipelineLastBuild: " + mavenWarPipelineLastRun + " caused by " + mavenWarPipelineLastRun.getCauses());
assertThat(mavenWarPipelineLastRun.getNumber(), is(mavenWarPipelineFirstRun.getNumber() + 1));
Cause.UpstreamCause upstreamCause = mavenWarPipelineLastRun.getCause(Cause.UpstreamCause.class);
assertThat(upstreamCause, notNullValue());
}