Skip to content

Commit

Permalink
CheckoutScript.doCheckout2
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Feb 24, 2025
1 parent 9de8c9f commit 1e9cc1e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AnyScript extends DeclarativeAgentScript<Any> {
Closure run(Closure body) {
return {
script.node {
CheckoutScript.doCheckout(script, describable, null, body).call()
CheckoutScript.doCheckout2(script, describable, null, body)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LabelScript extends DeclarativeAgentScript<Label> {
Closure run(Closure body) {
Closure run = {
script.node(describable?.label) {
CheckoutScript.doCheckout(script, describable, describable.customWorkspace, body).call()
CheckoutScript.doCheckout2(script, describable, describable.customWorkspace, body)
}
}
if (describable.retries > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ import org.jenkinsci.plugins.workflow.cps.CpsScript

class CheckoutScript implements Serializable {

// TODO define optimized version that runs body directly rather than returning Closure
@Deprecated
static Closure doCheckout(CpsScript script, DeclarativeAgent agent, String customWorkspace = null, Closure body) {
return {
if (customWorkspace) {
script.ws(customWorkspace) {
checkoutAndRun(script, agent, body)
}
} else {
doCheckout2(script, agent, customWorkspace, body)
}
}

static void doCheckout2(CpsScript script, DeclarativeAgent agent, String customWorkspace = null, Closure body) {
if (customWorkspace) {
script.ws(customWorkspace) {
checkoutAndRun(script, agent, body)
}
} else {
checkoutAndRun(script, agent, body)
}
}

private static void checkoutAndRun(CpsScript script, DeclarativeAgent agent, Closure body) {
def checkoutMap = [:]

Expand Down

0 comments on commit 1e9cc1e

Please sign in to comment.