Skip to content

Instantly share code, notes, and snippets.

@krishna-acondy
Last active June 26, 2019 11:03
Show Gist options
  • Save krishna-acondy/67d2cd8cedccc8e7936490cbfcac294a to your computer and use it in GitHub Desktop.
Save krishna-acondy/67d2cd8cedccc8e7936490cbfcac294a to your computer and use it in GitHub Desktop.
Jenkins CI Script
def dockerArtifactoryRegistry = "your-docker-registry-here"
def timestamp = new Date().format("MMddHHmmss", TimeZone.getTimeZone('UTC'))
pipeline {
agent {
node {
label 'docker'
customWorkspace "automated-ui-tests"
}
}
environment {
DOCKER_SUFFIX = "${timestamp}"
}
stages {
stage('Run tests') {
steps {
sh "docker-compose pull"
sh "docker-compose up -d"
dir("src/AutomatedUiTests") {
sh """
docker run --name automated-ui-tests-${DOCKER_SUFFIX} --rm \
--network automated-ui-tests-${DOCKER_SUFFIX} \
-e WebDriver__Type=remote \
-e WebDriver__Remote__HubUrl=http://selenium-hub-${DOCKER_SUFFIX}:4444/wd/hub \
-e ApplicationUrl=http://web-app-${DOCKER_SUFFIX} \
-v \$(pwd):/workspace \
-w /workspace mikemcfarland/gauge-dotnet \
/bin/bash -c 'gauge run Specs/; rtn=\$?; chown -R 1002:1002 .; exit \$rtn'
"""
}
}
}
}
post {
always {
sh "docker-compose down --remove-orphans"
sh "docker image prune -f"
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'src/AutomatedUiTests/Reports/html-report/',
reportFiles: 'index.html',
reportName: 'Gauge Report',
reportTitles: ''])
deleteDir()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment