-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-73224] Do not try to create a pod which already exists (#1561)
- Loading branch information
Showing
9 changed files
with
183 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...st/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/AssertBuildLogMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; | ||
|
||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.RealJenkinsRule; | ||
|
||
public class AssertBuildLogMessage implements RealJenkinsRule.Step { | ||
|
||
private final String message; | ||
private final RunId runId; | ||
|
||
public AssertBuildLogMessage(String message, RunId runId) { | ||
this.message = message; | ||
this.runId = runId; | ||
} | ||
|
||
@Override | ||
public void run(JenkinsRule r) throws Throwable { | ||
WorkflowJob p = r.jenkins.getItemByFullName(runId.name, WorkflowJob.class); | ||
WorkflowRun b = p.getBuildByNumber(runId.number); | ||
r.waitForMessage(message, b); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...csanchez/jenkins/plugins/kubernetes/pipeline/steps/CreateWorkflowJobThenScheduleTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; | ||
|
||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.RealJenkinsRule; | ||
|
||
/** | ||
* Creates a workflow job using the specified script, then schedules it and returns a reference to the run. | ||
*/ | ||
public class CreateWorkflowJobThenScheduleTask implements RealJenkinsRule.Step2<RunId> { | ||
private String script; | ||
|
||
public CreateWorkflowJobThenScheduleTask(String script) { | ||
this.script = script; | ||
} | ||
|
||
@Override | ||
public RunId run(JenkinsRule r) throws Throwable { | ||
WorkflowJob project = r.createProject(WorkflowJob.class); | ||
project.setDefinition(new CpsFlowDefinition(script, true)); | ||
project.save(); | ||
System.out.println("Scheduling build..."); | ||
WorkflowRun b = project.scheduleBuild2(0).getStartCondition().get(); | ||
System.out.println("Build scheduled..."); | ||
return new RunId(project.getFullName(), b.number); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/restartDuringPodLaunch.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
podTemplate(yaml: ''' | ||
apiVersion: v1 | ||
kind: Pod | ||
spec: | ||
nodeSelector: | ||
disktype: special | ||
''') { | ||
node(POD_LABEL) { | ||
sh 'true' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters