Tuesday, August 29, 2023

Jenkins Node Pipelines Parameterized

Jenkins

Login to Jenkins -> Click on New Item -> choose Pipeline -> Click Ok
On the configure page, select -> This project is parameterized

Enter Name and Choices

Go to Pipeline section and add the following Node code
node {
    if ("${GitRepos}" == "automation")
    {
        git "https://github.com/yashwanthsn2020/automation.git"
    }
    if ("${GitRepos}" == "yashwanthsn")
    {
        git "https://github.com/yashwanthsn2020/yashwanthsn.git"
    }
}
Click on save
Click on Build with Parameters
Select automation and Click on Build, it should clone the automation.git

Now try to build with yashwanthsn choices parameter