Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Last active November 18, 2019 00:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/a62e3790c6db7654808528bd5e5a385f to your computer and use it in GitHub Desktop.
Save jrichardsz/a62e3790c6db7654808528bd5e5a385f to your computer and use it in GitHub Desktop.
jenkins templates : scripted pipelines and declarative pipeline (Jenkinsfile)
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}
node {
echo 'New build for: '+params.repositoryName+' in branch '+params.branchName
}
node {
try{
stage 'checkout project'
checkout scm
stage 'check env'
sh "mvn -v"
sh "java -version"
stage 'test'
sh "mvn test"
stage 'package'
sh "mvn package"
stage 'report'
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
stage 'Artifact'
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
}catch(e){
throw e;
}
}
node {
echo 'New build detected with this incoming parameters: '+params
}
https://gist.github.com/jrichardsz/cdea67fe6357c9c51df04eaafc83e11c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment