Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brunocrt/0d0e8e51b213d9d809e18e14d98b4e39 to your computer and use it in GitHub Desktop.
Save brunocrt/0d0e8e51b213d9d809e18e14d98b4e39 to your computer and use it in GitHub Desktop.

Revisions

  1. Adam Eri revised this gist Jan 11, 2018. 1 changed file with 27 additions and 31 deletions.
    58 changes: 27 additions & 31 deletions example-jenkinsfile-pipeline.groovy
    Original file line number Diff line number Diff line change
    @@ -4,64 +4,60 @@ pipeline {
    agent any

    stages {
    stage('Checkout') {
    stage('Checkout') {
    steps {
    checkout scm
    }
    }

    stage('Dependecies') {
    steps {
    sh '/usr/local/bin/pod update'
    }
    }

    stage('Running Tests') {
    steps {
    echo 'Running Tests'
    sh 'fastlane scan'
    stage('Dependecies') {
    steps {
    sh '/usr/local/bin/pod install'
    }
    }

    stage('Generating Docs') {
    stage('Running Tests') {
    steps {
    parallel (
    "Jazzy": {
    sh 'jazzy'
    sh 'rm -rf /srv/deploy/bikemap-docs/ios/source'
    sh 'cp -a docs/source/. /srv/deploy/bikemap-docs/ios/reference'
    "Unit Tests": {
    sh 'echo "Unit Tests"'
    sh 'fastlane scan'
    },
    "Mkdocs": {
    sh 'cd docs/concepts && mkdocs build'
    sh 'rm -rf /srv/deploy/bikemap-docs/ios/concepts'
    sh 'cp -a docs/concepts/site/. /srv/deploy/bikemap-docs/ios/concept'
    "UI Automation": {
    sh 'echo "UI Automation"'
    }
    )
    }
    }

    stage('Distribution') {
    steps {
    // Building and packaging the app
    sh 'fastlane gym --silent'

    // Uploading to TestFlight/Hockey/etc.
    sh 'fastlane deliver'
    }
    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 {
    junit 'test_output/report.junit'
    // Processing test results
    junit 'fastlane/test_output/report.junit'
    // Cleanup
    sh 'rm -rf build'
    }
    success {
    // Slack notification about the success
    notifyBuild()
    }
    failure {
    // Slack notification about the failure
    notifyBuild('ERROR')
    }
    }
  2. Adam Eri revised this gist May 31, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion example-jenkinsfile-pipeline.groovy
    Original file line number Diff line number Diff line change
    @@ -61,7 +61,6 @@ pipeline {
    notifyBuild()
    }
    failure {

    // Slack notification about the failure
    notifyBuild('ERROR')
    }
  3. Adam Eri revised this gist May 31, 2017. 1 changed file with 13 additions and 12 deletions.
    25 changes: 13 additions & 12 deletions example-jenkinsfile-pipeline.groovy
    Original file line number Diff line number Diff line change
    @@ -23,19 +23,20 @@ pipeline {
    }
    }

    stage('Generating Docs') {
    stage('Generating Docs') {
    steps {
    // Jazzy for reference.
    sh 'jazzy'

    // MKDocs for high-level concepts
    sh 'mkdocs build'

    // Copying docs to public folder
    sh 'rm -rf /srv/deploy/docs/ios/concepts'
    sh 'rm -rf /srv/deploy/docs/ios/source'
    sh 'cp -a docs/concepts/site/. /srv/deploy/docs/ios/concept'
    sh 'cp -a docs/source/. /srv/deploy/docs/ios/reference'
    parallel (
    "Jazzy": {
    sh 'jazzy'
    sh 'rm -rf /srv/deploy/bikemap-docs/ios/source'
    sh 'cp -a docs/source/. /srv/deploy/bikemap-docs/ios/reference'
    },
    "Mkdocs": {
    sh 'cd docs/concepts && mkdocs build'
    sh 'rm -rf /srv/deploy/bikemap-docs/ios/concepts'
    sh 'cp -a docs/concepts/site/. /srv/deploy/bikemap-docs/ios/concept'
    }
    )
    }
    }

  4. Adam Eri created this gist May 26, 2017.
    100 changes: 100 additions & 0 deletions example-jenkinsfile-pipeline.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,100 @@
    #!groovy

    pipeline {
    agent any

    stages {
    stage('Checkout') {
    steps {
    checkout scm
    }
    }

    stage('Dependecies') {
    steps {
    sh '/usr/local/bin/pod update'
    }
    }

    stage('Running Tests') {
    steps {
    echo 'Running Tests'
    sh 'fastlane scan'
    }
    }

    stage('Generating Docs') {
    steps {
    // Jazzy for reference.
    sh 'jazzy'

    // MKDocs for high-level concepts
    sh 'mkdocs build'

    // Copying docs to public folder
    sh 'rm -rf /srv/deploy/docs/ios/concepts'
    sh 'rm -rf /srv/deploy/docs/ios/source'
    sh 'cp -a docs/concepts/site/. /srv/deploy/docs/ios/concept'
    sh 'cp -a docs/source/. /srv/deploy/docs/ios/reference'
    }
    }

    stage('Distribution') {
    steps {
    // Building and packaging the app
    sh 'fastlane gym --silent'

    // Uploading to TestFlight/Hockey/etc.
    sh 'fastlane deliver'
    }
    }
    }

    post {
    always {
    junit 'test_output/report.junit'
    sh 'rm -rf build'
    }
    success {
    // Slack notification about the success
    notifyBuild()
    }
    failure {

    // Slack notification about the 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")
    }