Advertisement
karthikvee

jenkins-parameterized-declarative-pipeline-script

Aug 31st, 2021
1,901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.57 KB | None | 0 0
  1. pipeline {
  2.     agent any
  3.     stages {
  4.         stage('Setup parameters') {
  5.             steps {
  6.                 script {
  7.                     properties([
  8.                         parameters([
  9.                             choice(
  10.                                 choices: ['DEV', 'STAGE', 'PROD'],
  11.                                 name: 'ENVIRONMENT'
  12.                             ),
  13.                             booleanParam(
  14.                                 defaultValue: true,
  15.                                 description: '',
  16.                                 name: 'BOOLEAN'
  17.                             ),
  18.                             text(
  19.                                 defaultValue: '''
  20.                                this is a multi-line
  21.                                string parameter example
  22.                                ''',
  23.                                  name: 'MULTI-LINE-STRING'
  24.                             ),
  25.                             string(
  26.                                 defaultValue: 'DevOps',
  27.                                 name: 'JOBROLE',
  28.                                 trim: true
  29.                             )
  30.                         ])
  31.                     ])
  32.                 }
  33.             }
  34.         }
  35.         stage('Deploy to Production') {
  36.             when {
  37.                 expression {
  38.                    return params.ENVIRONMENT == 'PROD'
  39.                 }
  40.             }
  41.             steps {
  42.                     sh """
  43.                    echo "deploy to production"
  44.                    """
  45.                 }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement