Commit 65e4549e authored by Raphael Defosseux's avatar Raphael Defosseux

feat(ci): always keeping a copy of CI temp image and also pushing to DockerHub on merged MR

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 2b3bf0a0
...@@ -114,6 +114,10 @@ pipeline { ...@@ -114,6 +114,10 @@ pipeline {
error "Stopping pipeline!" error "Stopping pipeline!"
} }
} }
if (params.DockerHubCredentials == null) {
echo '\u26D4 \u001B[31mNo Credentials to push to DockerHub!\u001B[0m'
error "Stopping pipeline!"
}
} }
} }
} }
...@@ -197,6 +201,10 @@ pipeline { ...@@ -197,6 +201,10 @@ pipeline {
myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/nrf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/nrf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
myShCmd('docker image ls >> archives/nrf_docker_image_build.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker image ls >> archives/nrf_docker_image_build.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// We will keep also the TMP image in U18 case.
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker image tag oai-nrf:' + nrf_tag + ' oai-nrf:' + rhel_nrf_tag, rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
} }
} }
} }
...@@ -433,6 +441,25 @@ pipeline { ...@@ -433,6 +441,25 @@ pipeline {
} }
} }
} }
// For the moment it is Docker-Hub, but we might have a new one internally.
stage ('Pushing Image to Official Registry') {
steps {
script {
// Only in case of push to target branch!
if ("PUSH".equals(env.gitlabActionType)) {
withCredentials([
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.DockerHubCredentials}", usernameVariable: 'DH_Username', passwordVariable: 'DH_Password']
]) {
myShCmd("echo ${DH_Password} | docker login --username ${DH_Username} --password-stdin", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker image tag oai-nrf:develop ${DH_Username}/oai-nrf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker push ${DH_Username}/oai-nrf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker rmi ${DH_Username}/oai-nrf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker logout", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
}
}
}
} }
post { post {
success { success {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment