From 25ada802f47a5ce77c214944e23fa8f86e6551fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20Hern=C3=A1ndez=20Sola?= Date: Tue, 4 Apr 2017 09:58:42 +0200 Subject: [PATCH] Added some scripts --- 03-multipleProperties.groovy | 8 +++--- 06-Saucelabs-Example.groovy | 51 ++++++++++++++++++++++++++++++++++++ 06-basicWhen.groovy | 23 ---------------- 07-Saucelabs-Example.groovy | 23 ---------------- 4 files changed, 54 insertions(+), 51 deletions(-) create mode 100644 06-Saucelabs-Example.groovy delete mode 100644 06-basicWhen.groovy delete mode 100644 07-Saucelabs-Example.groovy diff --git a/03-multipleProperties.groovy b/03-multipleProperties.groovy index 90b418e..6030e5b 100644 --- a/03-multipleProperties.groovy +++ b/03-multipleProperties.groovy @@ -1,5 +1,5 @@ pipeline { - agent none + agent any parameters { booleanParam(defaultValue: true, description: '', name: 'flag') // TODO: Be prepared to change this to "stringParam" once we're on a new enough core. @@ -8,7 +8,7 @@ pipeline { triggers { cron('@daily') } - properties { + options { buildDiscarder(logRotator(numToKeepStr:'1')) disableConcurrentBuilds() } @@ -19,6 +19,4 @@ pipeline { } } } -} - - +} \ No newline at end of file diff --git a/06-Saucelabs-Example.groovy b/06-Saucelabs-Example.groovy new file mode 100644 index 0000000..38d54e9 --- /dev/null +++ b/06-Saucelabs-Example.groovy @@ -0,0 +1,51 @@ +pipeline { + agent any + tools { + maven "maven_jenkins" + jdk "java_jenkins" + } + environment { + saucelabsCredentialId = '8b819d9d-0298-4f8f-9430-6d44e87ac7b5' + } + stages { + stage('Checkout') { + steps { + git url: 'git@github.com:Gromenaware/corball-test-automation-demo.git' + } + } + stage('Test') { + steps { + sh 'mvn -Dtest=WebDriverTest -Dbrowser=$BROWSER -Dhub=http://selgp:8b819d9d-0298-4f8f-9430-6d44e87ac7b5@ondemand.saucelabs.com:80/wd/hub test' + } + } + } + post { + success { + emailext ( + subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at ${env.BUILD_URL}""", + to: 'guillem@gromenaware.com' + ) + + } + failure { + emailext ( + subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at ${env.BUILD_URL}""", + to: 'guillem@gromenaware.com' + ) + } + always { + step([$class: 'XUnitBuilder', + thresholds: [ + [$class: 'SkippedThreshold', failureThreshold: '0'], + // Allow for a significant number of failures + // Keeping this threshold so that overwhelming failures are guaranteed + // to still fail the build + [$class: 'FailedThreshold', failureThreshold: '10']], + tools: [[$class: 'JUnitType', pattern: 'target/surefire-reports/junitreports/**']]]) + + saucePublisher() + } + } +} \ No newline at end of file diff --git a/06-basicWhen.groovy b/06-basicWhen.groovy deleted file mode 100644 index 37f7660..0000000 --- a/06-basicWhen.groovy +++ /dev/null @@ -1,23 +0,0 @@ -pipeline { - agent any - stages { - stage("One") { - steps { - echo "Hello" - } - } - stage("Two") { - when { - echo "Should I run?" - return true - } - steps { - script { - echo "World" - echo "Heal it" - } - - } - } - } -} \ No newline at end of file diff --git a/07-Saucelabs-Example.groovy b/07-Saucelabs-Example.groovy deleted file mode 100644 index 37f7660..0000000 --- a/07-Saucelabs-Example.groovy +++ /dev/null @@ -1,23 +0,0 @@ -pipeline { - agent any - stages { - stage("One") { - steps { - echo "Hello" - } - } - stage("Two") { - when { - echo "Should I run?" - return true - } - steps { - script { - echo "World" - echo "Heal it" - } - - } - } - } -} \ No newline at end of file