Created
January 23, 2023 11:53
-
-
Save akashdktyagi/eddc87cbfb2de2bbf8448c032a285509 to your computer and use it in GitHub Desktop.
Run Side Card Container With in a Jenkins Pipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def withDockerNetwork(Closure inner) { | |
try { | |
networkId = UUID.randomUUID().toString() | |
sh "docker network create ${networkId}" | |
inner.call(networkId) | |
} finally { | |
sh "docker network rm ${networkId}" | |
} | |
} | |
pipeline { | |
agent none | |
environment { | |
} | |
stages { | |
stage("test") { | |
agent any | |
steps { | |
script { | |
def selenium = docker.image("selenium/standalone-chrome:4.7.2-20221219")//, "grid-chrome") | |
def app = docker.image("temp/devcloud-build-java:11") | |
withDockerNetwork{ n -> | |
selenium.withRun("--network ${n} --name selenium -p 4444:4444") { c -> | |
app.inside(""" | |
--network ${n} -e 'gridUrl=http://selenium:4444' | |
""") { | |
sh 'mkdir -p ~/.m2/ && cp ${MAVEN_SETTINGS_PATH} ~/.m2/settings.xml' | |
sh 'mvn install' | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.kabisa.nl/tech/running-multiple-docker-containers-in-parallel-with-jenkins/