DevOps Classroom Series – 05/Dec/2021

Declarative Pipeline

  • The structural layout of the pipeline project appears as shown below
pipeline
{
    agent any
    stages {
        stage('<name of stage>') {
            steps {
                ...
            }
            post {

            }
        }
        stage('<name of stage>') {
            steps {
                ...
            }
            post {
                
            }
        }
    }
    post {

    }

}
  • Visual representation of structure

Triggering Jobs

  • In the free style project, we have the following options
  • In the Pipeline project jenkins ui shows the following options
  • To configure the pipelines in the
    • Free style project: => UI
    • Scripted pipeline, a properies can be specified
    • Declarative pipeline, triggers
  • Build after Other projects are built:
    • Freestyle
      • Save the configuration
      • Build the other project
      • Upstream project for this would be starterproject
      • For starter project freestyle project would be Downstream
    • Scripted:
    • Declartive Pipeline:
  • Build periodically:
    • In this case we want to trigger the build based on some schedule, and in linux to schedule we have cron job.
    • Jenkins uses this cron syntax to execute the jobs on schedule
    • To understand cronjobs Refer Here
    • Lets try to configure the
      • Free style project to run every 1/2 hour on weekdays (remove the upstream)
      • scripted pipeline to run every 3 hours on weekends (remove the upstream)
      • declarative pipeline to run every day @ 11:45 PM on week days
  • Poll SCM: In this we can poll the version control remote for changes & when the changes occur, we can trigger the build. But we need to configure how frequently we need to poll the SCM using cron syntax
    • Declarative pipeline: Lets configure for polling scm every 5 minutes

User Input

Parameters

  • when we build the project we will have a need to use parameters
  • Lets create some parameters for free style project
  • Lets create parameters where user will select
    • which branch to build
    • what will be maven goal => default goal is package
    • Now lets use this PARAMETERS in selecting the branch
    • For maven goal
    • Navigate to the project page
  • Lets give the same parameters from

Note

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%