DevOps Classroom Series – 26/Jul/2021

Working with Jenkins DSL

  • Jenkins DSL (Domain Specific Language) is written in Groovy Language
  • Groovy makes easier for Creating DSLs and we can use the DSL without much experience with groovy.
  • In this we will be looking at scripted pipeline
node ('GOL') {
    stage('SCM') {
        git 'https://github.com/asquarezone/game-of-life.git' # Step
    }
}
  • The node keyword is used to find the node on which the job can be executed

  • stage clouser allows us to group individual steps which contains DSL commands and logic. Every stage needs to have a unique name

  • With in the stage we write steps

  • Relation b/w node, stage and steps Preview

  • Creating Jenkinsfile steps with snippet generator Preview

  • We have created a scripted pipeline script to build the game of life

node('GOL') {
    stage('scm') {
        git 'https://github.com/asquarezone/game-of-life.git'
    }
    stage('build') {
        sh 'mvn clean package'
    }
    stage('postbuild') {
        junit '**/TEST-*.xml'
        archive '**/*.war'
    }
}
  • Exercise: Using the snippet generator create the Jenkinsfile for openmrs project
    • Fork the openmrs in your account
    • clone the repository into your system
    • Add a Jenkinsfile
    • IN the Jenkinsfile add scripted pipeline steps by using snippet generator

Leave a Reply

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

About learningthoughtsadmin