Skip to content

Instantly share code, notes, and snippets.

@darinpope
Created June 7, 2022 19:12
Show Gist options
  • Save darinpope/1dfd9b0fd71a808e73bde649b4d8abc5 to your computer and use it in GitHub Desktop.
Save darinpope/1dfd9b0fd71a808e73bde649b4d8abc5 to your computer and use it in GitHub Desktop.

Gist for https://youtu.be/u-1lyoas3ys

Documentation

Jenkinsfiles

Example 1

pipeline {
  agent any
  stages {
    stage('Hello') {
      steps {
        sh 'exit 0'
      }
    }
    stage('stage2') {
      steps {
        sh "echo stage2"
      }
    }
  }
}

Example 2

pipeline {
  agent any
  stages {
    stage('Hello') {
      steps {
        sh 'exit 1'
      }
    }
    stage('stage2') {
      steps {
        sh "echo stage2"
      }
    }
  }
}

Example 3

pipeline {
  agent any
  stages {
    stage('Hello') {
      steps {
        catchError {
          sh 'exit 1'
        }
      }
    }
    stage('stage2') {
      steps {
        sh "echo stage2"
      }
    }
  }
}

Example 4

pipeline {
  agent any
  stages {
    stage('Hello') {
      steps {
        catchError(message:'news') {
          sh 'exit 1'
        }
      }
    }
    stage('stage2') {
      steps {
        sh "echo stage2"
      }
    }
  }
}

Example 5

pipeline {
  agent any
  stages {
    stage('Hello') {
      steps {
        catchError(message:'news',buildResult:'UNSTABLE',stageResult:'UNSTABLE') {
          sh 'exit 1'
        }
      }
    }
    stage('stage2') {
      steps {
        sh "echo stage2"
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment