Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify AnyScript #532

Merged
merged 1 commit into from
May 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package org.jenkinsci.plugins.pipeline.modeldefinition.agent.impl

import org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentScript
import org.jenkinsci.plugins.workflow.cps.CpsScript

Expand All @@ -36,11 +37,10 @@ class AnyScript extends DeclarativeAgentScript<Any> {

@Override
Closure run(Closure body) {
Label l = (Label) Label.DescriptorImpl.instanceForName("label", [label: null])
l.copyFlags(describable)
Comment on lines -39 to -40
Copy link
Member Author

@jglick jglick May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note two methods which are no longer used in non-test code in this plugin but still used in https://github.com/jenkinsci/docker-workflow-plugin/blob/c7dedefcf68f6ce1320c8aaaeb831628ea21a086/src/main/java/org/jenkinsci/plugins/docker/workflow/declarative/DeclarativeDockerUtils.java#L91-L92 which could probably also be simplified along similar lines though I am not inclined to spend time on that plugin.

The analogous code in kubernetes is already straightforward: https://github.com/jenkinsci/kubernetes-plugin/blob/44fee1844a33a5946bf9f721edb9da64b7b7b3da/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgentScript.groovy#L52-L53

LabelScript labelScript = (LabelScript) l.getScript(script)
return labelScript.run {
body.call()
return {
script.node {
CheckoutScript.doCheckout(script, describable, null, body).call()
}
}
}
}
}