Skip to content

Commit

Permalink
Add ability to set network for Docker Custom Build Environment plugin (
Browse files Browse the repository at this point in the history
  • Loading branch information
guetta14 committed Jun 2, 2023
1 parent 0bb338e commit 94956e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Expand Up @@ -14,6 +14,7 @@ class BuildInDockerContext extends AbstractContext {
boolean forcePull
String userGroup
String startCommand = '/bin/cat'
String network = 'bridge'

BuildInDockerContext(JobManagement jobManagement) {
super(jobManagement)
Expand Down Expand Up @@ -78,4 +79,8 @@ class BuildInDockerContext extends AbstractContext {
void startCommand(String startCommand) {
this.startCommand = startCommand
}

void network(String network) {
this.network = network
}
}
Expand Up @@ -605,6 +605,7 @@ class WrapperContext extends AbstractExtensibleContext {
forcePull(context.forcePull)
group(context.userGroup ?: '')
command(context.startCommand ?: '')
net(context.network)
}
node.append(context.selector)
wrapperNodes << node
Expand Down
Expand Up @@ -1391,7 +1391,7 @@ class WrapperContextSpec extends Specification {
then:
with(context.wrapperNodes[0]) {
name() == 'com.cloudbees.jenkins.plugins.okidocki.DockerBuildWrapper'
children().size() == 9
children().size() == 10
selector[0].children().size() == 2
selector[0].attribute('class') == 'com.cloudbees.jenkins.plugins.okidocki.DockerfileImageSelector'
selector[0].contextPath[0].value() == '.'
Expand All @@ -1404,6 +1404,7 @@ class WrapperContextSpec extends Specification {
forcePull[0].value() == false
group[0].value().empty
command[0].value() == '/bin/cat'
net[0].value() == 'bridge'
}
1 * mockJobManagement.requireMinimumPluginVersion('docker-custom-build-environment', '1.6.2')
}
Expand All @@ -1422,12 +1423,13 @@ class WrapperContextSpec extends Specification {
verbose()
userGroup('test10')
startCommand('test11')
network('test12')
}

then:
with(context.wrapperNodes[0]) {
name() == 'com.cloudbees.jenkins.plugins.okidocki.DockerBuildWrapper'
children().size() == 9
children().size() == 10
selector[0].children().size() == 2
selector[0].attribute('class') == 'com.cloudbees.jenkins.plugins.okidocki.DockerfileImageSelector'
selector[0].contextPath[0].value() == 'test1'
Expand All @@ -1448,6 +1450,7 @@ class WrapperContextSpec extends Specification {
forcePull[0].value() == true
group[0].value() == 'test10'
command[0].value() == 'test11'
net[0].value() == 'test12'
}
1 * mockJobManagement.requireMinimumPluginVersion('docker-custom-build-environment', '1.6.2')
}
Expand All @@ -1466,12 +1469,13 @@ class WrapperContextSpec extends Specification {
verbose()
userGroup('test10')
startCommand('test11')
network('test12')
}

then:
with(context.wrapperNodes[0]) {
name() == 'com.cloudbees.jenkins.plugins.okidocki.DockerBuildWrapper'
children().size() == 9
children().size() == 10
selector[0].children().size() == 1
selector[0].attribute('class') == 'com.cloudbees.jenkins.plugins.okidocki.PullDockerImageSelector'
selector[0].image[0].value() == 'test1'
Expand All @@ -1491,6 +1495,7 @@ class WrapperContextSpec extends Specification {
forcePull[0].value() == true
group[0].value() == 'test10'
command[0].value() == 'test11'
net[0].value() == 'test12'
}
1 * mockJobManagement.requireMinimumPluginVersion('docker-custom-build-environment', '1.6.2')
}
Expand Down

0 comments on commit 94956e2

Please sign in to comment.