Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set network for Docker Custom Build Environment plugin #1340

Merged
merged 3 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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