generated from gCubeCI/Pipeline-Docker-Template
parent
378b764b61
commit
2e9027ad61
|
@ -5,44 +5,39 @@
|
||||||
|
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent { label 'CI'}
|
||||||
label 'docker'
|
tools {
|
||||||
|
maven 'Maven 3-6-2'
|
||||||
|
jdk 'OpenJDK 8'
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
imagename = "" //TO FILL WITH THE RIGHT VALUE (RepositoryName) e.g. d4science/RepositoryName
|
JAVA_HOME='/usr/lib/jvm/java-8-openjdk-amd64'
|
||||||
registryCredential = 'e348bfab-5580-4db6-b0e0-d854966bde08'
|
GIT_URL= "${params.GIT_URL}"
|
||||||
dockerImage = ''
|
GIT_BRANCH= "${params.GIT_BRANCH}"
|
||||||
git_url='' // SET HERE THE URL OF YOUR NEW GIT PROJECT
|
}
|
||||||
|
parameters {
|
||||||
|
string(name: 'GIT_URL',
|
||||||
|
defaultValue: '',
|
||||||
|
description: 'git url')
|
||||||
|
string(name: 'GIT_BRANCH',
|
||||||
|
defaultValue: '',
|
||||||
|
description: 'git branch')
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Cloning Git') {
|
stage('Checkout git project') {
|
||||||
steps {
|
steps {
|
||||||
git([url: git_url, branch: 'master', credentialsId: '88b54962-1c0e-49cb-8155-22276860f346'])
|
git branch: '${params.GIT_BRANCH}', credentialsId: '88b54962-1c0e-49cb-8155-22276860f346', url: '${params.GIT_URL}'
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Building image') {
|
stage('Build the job') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
sh 'mvn --settings $MAVEN_CONFIG_FOLDER/$gcube_settings -Dmaven.repo.local=$MAVEN_CONFIG_FOLDER/$local_repo $build_options dependency:tree clean deploy'
|
||||||
dockerImage = docker.build imagename
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy Image') {
|
stage('Clean') {
|
||||||
steps{
|
steps{
|
||||||
script {
|
sh "mvn clean"
|
||||||
docker.withRegistry( '', registryCredential ) {
|
|
||||||
dockerImage.push("$BUILD_NUMBER")
|
|
||||||
dockerImage.push('latest')
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Remove Unused docker image') {
|
|
||||||
steps{
|
|
||||||
sh "docker rmi $imagename:$BUILD_NUMBER"
|
|
||||||
sh "docker rmi $imagename:latest"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,15 +45,15 @@ pipeline {
|
||||||
// post-build actions
|
// post-build actions
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
echo 'The docker pipeline worked!'
|
echo 'The gCubeBuild pipeline worked!'
|
||||||
emailext to: 'jenkinsbuilds@d4science.org',
|
emailext to: 'roberto.cirillo@isti.cnr.it',
|
||||||
subject: "[Jenkins DockerPipeline D4S] build ${currentBuild.fullDisplayName} worked",
|
subject: "[Jenkins gCubeBuild Pipeline] build ${currentBuild.fullDisplayName} worked",
|
||||||
body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
|
body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo 'The docker pipeline has failed'
|
echo 'The gCubeBuild pipeline has failed'
|
||||||
emailext attachLog: true,
|
emailext attachLog: true,
|
||||||
to: 'jenkinsbuilds@d4science.org',
|
to: 'roberto.cirillo@isti.cnr.it',
|
||||||
subject: "[Jenkins DockerPipeline D4S] build ${currentBuild.fullDisplayName} failed for image ${imagename}",
|
subject: "[Jenkins DockerPipeline D4S] build ${currentBuild.fullDisplayName} failed for image ${imagename}",
|
||||||
body: "Something is wrong with ${env.BUILD_URL}"
|
body: "Something is wrong with ${env.BUILD_URL}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue