Add 'JenkinsFile'

add JenkinsFile configuration
This commit is contained in:
Roberto Cirillo 2023-11-21 16:35:39 +01:00
parent 1f703a42d1
commit 61dd99b63a
1 changed files with 44 additions and 0 deletions

44
JenkinsFile Normal file
View File

@ -0,0 +1,44 @@
pipeline {
agent {
label 'docker'
}
environment {
imagename = "d4science/gcore-resource-manager"
registryCredential = 'e348bfab-5580-4db6-b0e0-d854966bde08'
dockerImage = ''
git_url='https://code-repo.d4science.org/gCubeSystem/resource-manager-image.git'
}
stages {
stage('Cloning Git') {
steps {
git([url: git_url, branch: 'main', 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"
}
}
}
}