Tuesday, August 29, 2023

Jenkins Node Pipelines

 Jenkins


To create a Node in the pipelines structure, use the below step
node('exec') {
// some block
}

Click on New Item -> Pipeline -> under Pipeline section add the below code. When the integer value is zero, clone automation.git
node {
    i = 0
    if (i == 0)
    {
        echo "Value of i is $i"
        git "https://github.com/yashwanthsn2020/automation.git"
    }
Build the pipeline
Console Output
Add the below Node step to clone two repos based on the integer value
node {
    i = 0
    if (i == 0)
    {
        echo "Value of i is $i"
        git "https://github.com/yashwanthsn2020/automation.git"
    }
    i+=1
    if (i == 1)
    {
        echo "Value of i is $i"
        git "https://github.com/yashwanthsn2020/yashwanthsn.git"
    }
}
Click on Build Now and check the Console output