#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Jenkins · Topic 13 of 15

Pipeline Parameters (String, Boolean, Choice)

Why Parameters in a Pipeline?

Instead of manually selecting parameters through the GUI every time, we can define them directly in the pipeline code using a parameters block placed right after agent.

String Parameter

pipeline {
    agent any
    parameters {
        string(name: "person", defaultValue: "Sandeep", description: "")
    }
    stages {
        stage('Hello') {
            steps {
                sh 'echo "hi my name is $person"'
            }
        }
    }
}

Boolean Parameter

pipeline {
    agent any
    parameters {
        booleanParam(name: "db", defaultValue: true, description: "")
    }
    stages {
        stage('Hello') {
            steps {
                sh 'echo "hi this is boolean parameters"'
            }
        }
    }
}

If defaultValue is true, the checkbox appears checked (enabled) on the Build with Parameters screen; false leaves it unchecked.

Choice Parameter

pipeline {
    agent any
    parameters {
        choice(name: "file", choices: ["sandeep", "chikkala", "sandy", "bablu"], description: "")
    }
    stages {
        stage('Choice Parameter') {
            steps {
                sh 'echo "touch $file"'
            }
        }
    }
}

On "Build with Parameters" you get a dropdown to pick one of the listed choices, which then feeds into the shell command.

Master Jenkins & DevOps with Uncodemy

Hands-on live training, real projects, and placement support — become job-ready in DevOps.

Enroll in DevOps Training →