Monday, February 28, 2022

Jenkins- CICD using Declarative Pipeline

1. Create a Project Pipelinejob of Project Type Pipeline

2. In the Groovy sandbox write following script and execute the code

  1.    pipeline {
  2.     agent any

  3.     tools {
  4.         // Install the Maven version configured as "M3" and add it to the path.
  5.         maven "mvn1"
  6.     }

  7.     stages {
  8.         stage('Build') {
  9.             steps {
  10.                 // Get some code from a GitHub repository
  11.                git 'https://github.com/onlineTrainingguy/jenkinscicd.git'

  12.                 // Run Maven on a Unix agent.
  13.                 sh "mvn clean package"

  14.                 // To run Maven on a Windows agent, use
  15.                 // bat "mvn -Dmaven.test.failure.ignore=true clean package"
  16.             }

  17.         }
  18.     }
  19. }

3. save and Build the script

4. For Jenkinsfile, Create a Jenkins file in the Github repo (use this reference for jenkins file https://github.com/onlineTrainingguy/jenkinscicd.git)

5. Select Git in the pipeline project and Build the job.

0 comments:

Post a Comment