1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-02-05 13:25:19 +02:00

feat(dub): expose dockerEnvVars and dockerWorkspace in dubExecute (#1012)

This commit is contained in:
andre2007 2019-12-09 16:24:11 +01:00 committed by Christopher Fenner
parent 481f635e32
commit 80e433aaf9
2 changed files with 38 additions and 1 deletions

View File

@ -40,6 +40,32 @@ class DubExecuteTest extends BasePiperTest {
assertEquals 'dlang2/dmd-ubuntu:latest', dockerExecuteRule.dockerParams.dockerImage
}
@Test
void testDockerFromCustomStepConfiguration() {
def expectedImage = 'image:test'
def expectedEnvVars = ['env1': 'value1', 'env2': 'value2']
def expectedOptions = '--opt1=val1 --opt2=val2 --opt3'
def expectedWorkspace = '/path/to/workspace'
nullScript.commonPipelineEnvironment.configuration = [steps:[dubExecute:[
dockerImage: expectedImage,
dockerOptions: expectedOptions,
dockerEnvVars: expectedEnvVars,
dockerWorkspace: expectedWorkspace
]]]
stepRule.step.dubExecute(
script: nullScript,
juStabUtils: utils
)
assert expectedImage == dockerExecuteRule.dockerParams.dockerImage
assert expectedOptions == dockerExecuteRule.dockerParams.dockerOptions
assert expectedEnvVars.equals(dockerExecuteRule.dockerParams.dockerEnvVars)
assert expectedWorkspace == dockerExecuteRule.dockerParams.dockerWorkspace
}
@Test
void testDubExecuteWithClosure() {
stepRule.step.dubExecute(script: nullScript, dockerImage: 'dlang2/dmd-ubuntu:latest', dubCommand: 'build') { }

View File

@ -11,6 +11,12 @@ import groovy.transform.Field
* Name of the docker image that should be used, in which node should be installed and configured. Default value is 'dlang2/dmd-ubuntu:latest'.
*/
'dockerImage',
/** @see dockerExecute*/
'dockerEnvVars',
/** @see dockerExecute */
'dockerOptions',
/** @see dockerExecute*/
'dockerWorkspace',
/**
* URL of default DUB registry
*/
@ -52,7 +58,12 @@ void call(Map parameters = [:], body = null) {
if (!fileExists('dub.json') && !fileExists('dub.sdl')) {
error "[${STEP_NAME}] Neither dub.json nor dub.sdl was found."
}
dockerExecute(script: script, dockerImage: configuration.dockerImage, dockerOptions: configuration.dockerOptions) {
dockerExecute(script: script,
dockerImage: configuration.dockerImage,
dockerEnvVars: configuration.dockerEnvVars,
dockerOptions: configuration.dockerOptions,
dockerWorkspace: configuration.dockerWorkspace
) {
if (configuration.defaultDubRegistry) {
sh """
mkdir ~/.dub