Tuesday 3 August 2021

How to create parameterized job in Jenkins? What is parameterized build in Jenkins?

 











 How to send email notification with groovy script in Jenkins pipeline?

Pipeline Script Fundamentals

Click Here :   DevOps Related Posts


Step 1. Create a freestyle Job.

Create a freestyle job with an appropriate name.




Step 2. Create Parameters option from the dropdown.

  Select This project is parameterized in the General section

  Click Add Parameter.

  Select Choice Parameter



Step 3. Configure Choice Parameter

Configure the fields as follows

  Name – give a suitable name for your parameter. For eg. Environment

  Choices – give the values one per line that will appear in the drop-down option.

  Description – describe the parameter.



Step 4. Configure Build Step.

  Choose Execute Shell and print something using the parameter.




********************

HOW TO INSTALL DOCKER IN WINDOWS AND MAC

********************


Step 5. Build the project.

  Click on Build with Parameters

  Choose any value from the drop-down and click on Build, you will see all the choice parameters here in the dropdown



Step 6. Check the Console Output.

In the console, the selected value gets printed instead of $OS. You build the project with different values from the drop-down and you will always get the selected value in console output.



There are many parameters available in Jenkins:

Available Parameters
string

A parameter of a string type, for example: parameters { string(name: 'DEPLOY_ENV', defaultValue: 'staging', description: '') }

text

A text parameter, which can contain multiple lines, for example: parameters { text(name: 'DEPLOY_TEXT', defaultValue: 'One\nTwo\nThree\n', description: '') }

booleanParam

A boolean parameter, for example: parameters { booleanParam(name: 'DEBUG_BUILD', defaultValue: true, description: '') }

choice

A choice parameter, for example: parameters { choice(name: 'CHOICES', choices: ['one', 'two', 'three'], description: '') }

password

A password parameter, for example: parameters { password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'A secret password') }

Example 10. Parameters, Declarative Pipeline
pipeline {
    agent any
    parameters {
        string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')

        text(name: 'BIOGRAPHY', defaultValue: '', description: 'Enter some information about the person')

        booleanParam(name: 'TOGGLE', defaultValue: true, description: 'Toggle this value')

        choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something')

        password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'Enter a password')
    }
    stages {
        stage('Example') {
            steps {
                echo "Hello ${params.PERSON}"

                echo "Biography: ${params.BIOGRAPHY}"

                echo "Toggle: ${params.TOGGLE}"

                echo "Choice: ${params.CHOICE}"

                echo "Password: ${params.PASSWORD}"
            }
        }
    }
}

 API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

SeleniumWebdriver Automation Testing Interview Questions:

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions


All Time Popular Posts

Most Featured Post

API Status Codes with examples for QA-Testers

  🔺 LinkedIn: https://www.linkedin.com/in/sidharth-shukla-77b53145/ 🔺 Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 🏮In API testing, it...