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 Preview

Triggering Jobs

  • In the free style project, we have the following options Preview
  • In the Pipeline project jenkins ui shows the following options Preview
  • 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 Preview
      • Build the other project Preview Preview
      • Upstream project for this would be starterproject Preview
      • For starter project freestyle project would be Downstream Preview
    • 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) Preview
      • 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 Preview
  • Lets create parameters where user will select
    • which branch to build Preview
    • what will be maven goal => default goal is package Preview
    • Now lets use this PARAMETERS in selecting the branch Preview
    • For maven goal Preview
    • Navigate to the project page Preview Preview
  • Lets give the same parameters from

Note

Leave a Reply

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube