From e0c6c9ce1455428e7e1616f0c75842c7cce75573 Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Thu, 31 Mar 2022 17:01:08 +0200 Subject: [PATCH] add Jenkinsfile --- Jenkinsfile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..80c9b01 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,51 @@ +// REMEMBER TO FILL THE environment section with your values. +// the following filed should be filled: imagename, git_url +// REMEMBER to put your Dockerfile in the root folder of your project +// The related jenkinsjob template is here: + +pipeline { + agent { + label 'docker' + } + environment { + imagename = "d4science/r-full" //TO FILL WITH THE RIGHT VALUE (RepositoryName) e.g. d4science/RepositoryName + registryCredential = 'e348bfab-5580-4db6-b0e0-d854966bde08' + dockerImage = '' + git_url='https://code-repo.d4science.org/gCubeSystem/docker-r-full.git' // SET HERE THE URL OF YOUR NEW GIT PROJECT + } + stages { + stage('Cloning Git') { + steps { + git([url: git_url, branch: 'master', credentialsId: '88b54962-1c0e-49cb-8155-22276860f346']) + + } + } + stage('Building image') { + steps{ + script { + dockerImage = docker.build imagename + } + } + } + stage('Deploy Image') { + steps{ + script { + 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" + + } + } + } +} + +