Forked from eriadam/example-jenkinsfile-pipeline.groovy
Created
January 19, 2021 03:32
-
-
Save namcxn/7809a788a16b509d0223dbbcb46a0e89 to your computer and use it in GitHub Desktop.
example-jenkinsfile-pipeline.groovy
This file contains hidden or 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