Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akashdktyagi/1ab6bf4983782109d06a85a38b524072 to your computer and use it in GitHub Desktop.
Save akashdktyagi/1ab6bf4983782109d06a85a38b524072 to your computer and use it in GitHub Desktop.
Run Selenium container in Dockerized Jenkins agent. Selenium mini grid
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