0% found this document useful (0 votes)
14 views1 page

Jenkins Pipeline for Maven Build

The document outlines a Jenkins pipeline configuration that includes stages for fetching code, building the project, testing, and performing code analysis. It utilizes Maven and JDK tools, and incorporates custom Groovy functions for printing messages. The pipeline archives build artifacts upon successful completion of the build stage.

Uploaded by

bieda2q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Jenkins Pipeline for Maven Build

The document outlines a Jenkins pipeline configuration that includes stages for fetching code, building the project, testing, and performing code analysis. It utilizes Maven and JDK tools, and incorporates custom Groovy functions for printing messages. The pipeline archives build artifacts upon successful completion of the build stage.

Uploaded by

bieda2q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

def myFunctions = load './myFunctions.

groovy'

pipeline {
agent any
tools {
maven "MAVEN3"
jdk "OracleJDK8"
}
environment {
PRINT_OK='ok'
PRINT_FAIL='fail'
}

stages {
stage('fetch code') {
steps {
git branch: 'jenkins_sonar_nexus', url:
"https://github.com/jkb91jkb91/vprofile_project/"
}
}

stage('Build') {
steps {
script {
echo "${env.PRINT_OK}"
myFunctions.printSomething()
myFunctions.printWithColor("colored text")
sh 'mvn --version'
sh 'mvn install -DskipTests'
}
}
post {
success {
archiveArtifacts artifacts: '**/*.war'
}
}
}

stage('Test') {
steps {
sh 'mvn test'
}
}

stage('Code Analysis') {
steps {
sh 'mvn checkstyle:checkstyle'
}
}
}
}

def printSomething() {
echo "groovy func"
}

def printWithColor(param) {
echo "\u001B[31m${param}\u001B[0m"
}

You might also like