Skip to content

Commit

Permalink
Declarative: do not wrap steps with container statement unless default
Browse files Browse the repository at this point in the history
container is changed

We met a weird issue when migrating the scripted syntax to declarative
with Kubernetes plugin: The `Launcher` doesn't forward `stdin`,
`stdout`, or `stderr` even though they are requested to be forwarded.
This breaks many plugins that use `Launcher` to start a remote process on Jenkins slaves.

This happens because when Kubernetes plugin converts declarative syntax to scripted syntax,
all build steps are enclosed with a `container` statement.
As a result, remote commands are run via the Kubernetes exec API rather than
the jnlp agent.

Since running steps via Kubernetes exec API is still considered ALPHA
and there are some compatibility issues to solve,
I would like to make a small change to the syntax converting process:
When the steps will not be enclosed with a `container` statement unless
an alternate default container is specified by the pipeline user.
  • Loading branch information
vfreex committed Sep 4, 2018
1 parent bd31c45 commit aeeb027
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ public class KubernetesDeclarativeAgentScript extends DeclarativeAgentScript<Kub
}

// call the main body
script.container(container) {
if (container == 'jnlp') {
// If default container is not specified by the user,
// do not wrap the body with `container` statement.
body.call()
} else {
script.container(container) {
body.call()
}
}
}.call()
}
Expand Down

0 comments on commit aeeb027

Please sign in to comment.