Created
May 15, 2023 03:40
-
-
Save akashdktyagi/1ab6bf4983782109d06a85a38b524072 to your computer and use it in GitHub Desktop.
Run Selenium container in Dockerized Jenkins agent. Selenium mini grid
This file contains hidden or 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
try { | |
networkId = UUID.randomUUID().toString() | |
sh "docker network create ${networkId}" | |
inner.call(networkId) | |
} finally { | |
sh "docker network rm ${networkId}" | |
} | |
} | |
pipeline { | |
agent none | |
stages { | |
stage("test") { | |
agent any | |
steps { | |
script { | |
def selenium = docker.image("selenium/standalone-chrome", "grid-chrome") | |
def app = docker.image("java/build-java:11") | |
withDockerNetwork{ n -> | |
selenium.withRun("--network ${n} --name selenium") { c -> | |
app.inside(""" | |
--network ${n} | |
""") { | |
sh " mvn install $MAVEN_CLI_OPTS -DrunWith=seleniumAsService -DgridUrl=grid-chrome" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment