Forked from eriadam/example-jenkinsfile-pipeline.groovy
Created
February 15, 2019 12:29
-
-
Save brunocrt/0d0e8e51b213d9d809e18e14d98b4e39 to your computer and use it in GitHub Desktop.
example-jenkinsfile-pipeline.groovy
This file contains 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
#!groovy | |
pipeline { | |
agent any | |
stages { | |
stage('Checkout') { | |
steps { | |
checkout scm | |
} | |
} | |
stage('Dependecies') { | |
steps { | |
sh '/usr/local/bin/pod install' | |
} | |
} | |
stage('Running Tests') { | |
steps { | |
parallel ( | |
"Unit Tests": { | |
sh 'echo "Unit Tests"' | |
sh 'fastlane scan' | |
}, | |
"UI Automation": { | |
sh 'echo "UI Automation"' | |
} | |
) | |
} | |
} | |
stage('Documentation') { | |
when { | |
expression { | |
env.BRANCH_NAME == 'develop' | |
} | |
} | |
steps { | |
// Generating docs | |
sh 'jazzy' | |
// Removing current version from web server | |
sh 'rm -rf /path/to/doc/ios' | |
// Copy new docs to web server | |
sh 'cp -a docs/source/. /path/to/doc/ios' | |
} | |
} | |
} | |
post { | |
always { | |
// Processing test results | |
junit 'fastlane/test_output/report.junit' | |
// Cleanup | |
sh 'rm -rf build' | |
} | |
success { | |
notifyBuild() | |
} | |
failure { | |
notifyBuild('ERROR') | |
} | |
} | |
} | |
// Slack notification with status and code changes from git | |
def notifyBuild(String buildStatus = 'SUCCESSFUL') { | |
buildStatus = buildStatus | |
def colorName = 'RED' | |
def colorCode = '#FF0000' | |
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" | |
def changeSet = getChangeSet() | |
def message = "${subject} \n ${changeSet}" | |
if (buildStatus == 'SUCCESSFUL') { | |
color = 'GREEN' | |
colorCode = '#00FF00' | |
} else { | |
color = 'RED' | |
colorCode = '#FF0000' | |
} | |
slackSend (color: colorCode, message: message) | |
} | |
@NonCPS | |
// Fetching change set from Git | |
def getChangeSet() { | |
return currentBuild.changeSets.collect { cs -> | |
cs.collect { entry -> | |
"* ${entry.author.fullName}: ${entry.msg}" | |
}.join("\n") | |
}.join("\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment