2019-02-18 09:20:16 +02:00
# ${docGenStepName}
2017-12-06 13:03:06 +02:00
2019-02-18 09:20:16 +02:00
## ${docGenDescription}
2017-12-06 13:03:06 +02:00
2019-02-18 09:20:16 +02:00
## ${docGenParameters}
2017-12-06 13:03:06 +02:00
2018-08-21 15:45:59 +02:00
## Kubernetes support
2018-11-06 14:50:09 +02:00
2018-10-04 17:06:42 +02:00
If the Jenkins is setup on a Kubernetes cluster, then you can execute the closure inside a container of a pod by setting an environment variable `ON_K8S` to `true` . However, it will ignore `containerPortMappings` , `dockerOptions` and `dockerVolumeBind` values.
2018-08-21 15:45:59 +02:00
2019-02-18 09:20:16 +02:00
## ${docGenConfiguration}
2018-10-04 17:06:42 +02:00
2019-05-24 15:44:31 +02:00
## ${docJenkinsPluginDependencies}
2019-05-24 15:41:49 +02:00
2018-08-21 15:45:59 +02:00
## Side effects
2018-11-06 14:50:09 +02:00
2018-08-21 15:45:59 +02:00
none
2017-12-06 13:03:06 +02:00
2018-08-21 15:45:59 +02:00
## Exceptions
2018-11-06 14:50:09 +02:00
2018-08-21 15:45:59 +02:00
none
2018-10-04 17:06:42 +02:00
## Example 1: Run closure inside a docker container
2017-12-06 13:03:06 +02:00
```groovy
dockerExecute(dockerImage: 'maven:3.5-jdk-7'){
sh "mvn clean install"
}
```
2018-11-06 14:50:09 +02:00
2018-08-21 15:45:59 +02:00
## Example 2: Run closure inside a container in a kubernetes pod
```sh
2018-10-04 17:06:42 +02:00
# set environment variable
2018-08-21 15:45:59 +02:00
export ON_K8S=true"
```
```groovy
dockerExecute(script: this, dockerImage: 'maven:3.5-jdk-7'){
sh "mvn clean install"
}
```
2018-10-04 17:06:42 +02:00
In the above example, the `dockerEcecute` step will internally invoke [dockerExecuteOnKubernetes ](dockerExecuteOnKubernetes.md ) step and execute the closure inside a pod.
2018-11-06 14:50:09 +02:00
## Example 3: Run closure inside a container which is attached to a sidecar container (as for example used in [seleniumExecuteTests](seleniumExecuteTests.md)
2018-10-04 17:06:42 +02:00
```groovy
dockerExecute(
script: script,
containerPortMappings: [containerPortMappings:'selenium/standalone-chrome':[containerPort: 4444, hostPort: 4444]],
dockerImage: 'node:8-stretch',
dockerName: 'node',
dockerWorkspace: '/home/node',
sidecarImage: 'selenium/standalone-chrome',
sidecarName: 'selenium',
) {
2019-11-11 18:40:23 +02:00
git url: 'https://github.com/XXXXX/WebDriverIOTest.git'
2018-10-04 17:06:42 +02:00
sh '''npm install
node index.js
'''
}
```