Use standard POD_LABEL rather than rolling your own - #3
Conversation
|
@jglick what does the built in POD LABEL create? If it some form of uuid |
|
No, it is derived from the job/build information, sanitized for K8s, and some random padding added. https://github.com/jenkinsci/kubernetes-plugin/blob/4818b920926399806d77b694d5b573aab580ad48/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java#L74 + https://github.com/jenkinsci/kubernetes-plugin/blob/4818b920926399806d77b694d5b573aab580ad48/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java#L179-L188 |
|
Basically the idea is that if you are using the |
|
@jglick I think some tests need updating 👍 I think the |
…t` (acc. to openshift.com `OpenShift` would be better but that may be incompatible)
|
I tried diff --git test/src/com/lilly/cirrus/jenkinsdsl/openshift/OpenshiftClientSpec.groovy test/src/com/lilly/cirrus/jenkinsdsl/openshift/OpenshiftClientSpec.groovy
index 7a79522..a7d1f67 100644
--- test/src/com/lilly/cirrus/jenkinsdsl/openshift/OpenshiftClientSpec.groovy
+++ test/src/com/lilly/cirrus/jenkinsdsl/openshift/OpenshiftClientSpec.groovy
@@ -70,7 +70,7 @@ class OpenshiftClientSpec extends CirrusDSLSpec {
String podNamespace = "cje-slaves-freestyle-dmz"
String containerName = "my-container"
JenkinsSim pipeline = createJenkinsSim()
- pipeline.withEnv([JOB_NAME: this.getTestString(45)])
+ pipeline.withEnv([JOB_NAME: this.getTestString(45), POD_LABEL: 'test'])
pipeline.withCredentialBinding("cred-id", [USER: "user", PASSWORD: "password"])
OpenshiftClient openShiftClient = new OpenshiftClient(jenkins: pipeline)
@@ -81,7 +81,7 @@ class OpenshiftClientSpec extends CirrusDSLSpec {
openShiftClient.runInPod(podNamespace, containerName, { closureExecuted = true })
then: "pipeline executes needed pipeline actions"
- pipeline.anchor(SimFactory.node({ label -> label.startsWith("oc-dsl") }))
+ pipeline.anchor(SimFactory.node({ label -> label == 'test' }))
.next(SimFactory.container(containerName))
and: "the closure gets executed"without success; the error messages from the mock framework are cryptic to me: |
Summary
As of jenkinsci/kubernetes-plugin#539 you should not need to explicitly come up with a pod label.
Submitter's Pledge
Reviewers, I have verified the following to the best of my knowledge:
CHANGELOG.mdwith the new target version (or with theUnreleasedtag) and updated the version comparison url in the file.README.mdat the repo root and all of the applicableREADME.mdfiles underdocs/**along with necessary version change for code samples in those docs where applicable.Review Recommendation
Nothing specific; do changes of this kind get test coverage?