Posts

Showing posts with the label Pipeline

Jenkins Declarative Pipeline

Image
Sample Jenkins Declarative Pipeline def A = false def B = true pipeline { agent any tools { maven 'MVN' jdk 'JDK' } stages { stage('Build Stage') { steps { git "https://github.com/nishantautomationlabs/nal-junitmockito.git" sh "mvn -U clean compile install -DskipTests" echo 'Build Stage executed' } } stage('Unit Test Stage') { steps { sh "mvn -Dtest=MockitoExampleTest test" echo 'Unit Test Stage executed' } } stage('Master Stage'){ when{ branch 'master' } steps { echo 'run this stage only if its running on the master branch' } } stage('Conditional Stage') { when { ...

Jenkins Scripted Pipeline

Image
Sample Jenkins Scripted Pipeline node { stage "Git Pull" git "https://github.com/nishantautomationlabs/nal-junitmockito.git" echo "code pulled" stage "Run Declarative Pipeline" build "Declarative Pipeline" echo "Declarative Pipeline triggered" stage "print" for(int i = 0; i < 10; i++) { if(i % 2 == 0) { echo "Number " + i } } } Jenkins Configuration: Build History: