Skip to content

Commit adfbe05

Browse files
committed
[JENKINS-58631] Document defaultContainer for declarative
1 parent 2d08f24 commit adfbe05

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,28 @@ pipeline {
494494
}
495495
```
496496

497+
Run steps within a container by default. Steps will be nested within an implicit `container(name) {...}` block instead
498+
of being executed in the jnlp container.
499+
500+
```
501+
pipeline {
502+
agent {
503+
kubernetes {
504+
defaultContainer 'maven'
505+
yamlFile 'KubernetesPod.yaml'
506+
}
507+
}
508+
509+
stages {
510+
stage('Run maven') {
511+
steps {
512+
sh 'mvn -version'
513+
}
514+
}
515+
}
516+
}
517+
```
518+
497519
Run the Pipeline or individual stage within a custom workspace - not required unless explicitly stated.
498520

499521
```

src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent/config.jelly

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<f:entry field="namespace" title="${%Namespace}">
77
<f:textbox/>
88
</f:entry>
9+
<f:entry field="defaultContainer" title="${%Default container}">
10+
<f:textbox/>
11+
</f:entry>
912
<f:entry field="inheritFrom" title="${%Pod template to inherit from}">
1013
<f:select/>
1114
</f:entry>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p>Name of the default container steps will be run in.</p>
2+
3+
<p>When using this option, all steps will be executed within an implicit <code>container(name) {...}</code> block instead
4+
of the jnlp container.</p>

0 commit comments

Comments
 (0)