def vividusNetwork = 'vividus-grid'(1)
def vividusHub = 'vividus-hub'(2)
def vividusBrowser = 'vividus-browser'(3)
def vividusProxyHost = 'vividus-proxy-host'(4)
def seleniumVersion = '4.5.0'(5)
def overridings = """
proxy.host=${vividusProxyHost}(4)
proxy.connectable-host=${vividusProxyHost}(4)
configuration.suites=web_app
configuration.profiles=web/docker,web/desktop/chrome
selenium.grid.url=http://${vividusHub}:4444/wd/hub(2)
"""
def projectName = 'vividus-sample-tests'(6)
def scmCredentialId = 'vividus'(7)
def gitUrl = 'git@github.com:vividus-framework/vividus-sample-tests.git'(8)
pipeline {
agent {
label 'docker'
}
stages {
stage('Start Selenium Grid') {
steps {
sh "docker network create ${vividusNetwork}"(1)
sh "docker run -d --net ${vividusNetwork} --name ${vividusHub} selenium/hub:${seleniumVersion}"(2)
sh "docker run -d --net ${vividusNetwork} -e SE_EVENT_BUS_HOST=${vividusHub} -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1080 --shm-size=2g --name ${vividusBrowser} selenium/node-chrome:${seleniumVersion}"(3)(5)
}
}
stage('Load Source') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: 'main']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'RelativeTargetDirectory', relativeTargetDir: projectName],(6)
[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]
],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: scmCredentialId, url: gitUrl]]])(7) (8)
}
}
stage('Run Tests Using Docker') {
steps {
sh "docker ps -a"
withDockerContainer(image: 'eclipse-temurin:21', args: "--net ${vividusNetwork} --name ${vividusProxyHost}") {(1) (4)
dir(projectName) {(6)
sh """ (9)
echo -e "${overridings}" > overriding.properties
mv -f overriding.properties src/main/resources/overriding.properties
./gradlew runStories
"""
archiveArtifacts 'output/reports/**'
}
}
}
}
}
post {
always {
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "${projectName}/output/reports/allure",(6)
reportFiles: 'index.html',
reportName: 'Allure Report',
reportTitles: ''
])
cleanWs()
sh "docker rm -vf ${vividusBrowser} || true"
sh "docker rm -vf ${vividusHub} || true"
sh "docker network rm ${vividusNetwork} || true"
}
}
}