nexus deploy
This commit is contained in:
parent
743d9f0894
commit
60c8265afc
|
|
@ -6,9 +6,15 @@ String extractBaseVersion(String pom) {
|
||||||
return matcher.find() ? matcher.group(1) : null
|
return matcher.find() ? matcher.group(1) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
NEXUS_URL = 'http://172.16.0.59:8081/repository/docker/'
|
||||||
|
NEXUS_CREDENTIALS_ID = 'nexus_cred'
|
||||||
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Set build number into version') {
|
stage('Set build number into version') {
|
||||||
steps {
|
steps {
|
||||||
|
|
@ -43,7 +49,31 @@ pipeline {
|
||||||
sh "docker build -f Dockerfile -t pfsdn:${VERSION} ."
|
sh "docker build -f Dockerfile -t pfsdn:${VERSION} ."
|
||||||
echo "Saving docker image pfsdn:${VERSION}"
|
echo "Saving docker image pfsdn:${VERSION}"
|
||||||
sh "docker save pfsdn:${VERSION} | gzip > pfsdn-${VERSION}.tar.gz"
|
sh "docker save pfsdn:${VERSION} | gzip > pfsdn-${VERSION}.tar.gz"
|
||||||
sh "docker rmi pfsdn:${VERSION} || true"
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Push docker image to Nexus') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def nexusHost = NEXUS_URL
|
||||||
|
.replaceAll(/^https?:\/\//, '')
|
||||||
|
.replaceAll(/\/+$/, '')
|
||||||
|
def nexusImage = "${nexusHost}/pfsdn:${VERSION}"
|
||||||
|
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: NEXUS_CREDENTIALS_ID,
|
||||||
|
usernameVariable: 'NEXUS_USER',
|
||||||
|
passwordVariable: 'NEXUS_PASS'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "\${NEXUS_PASS}" | docker login ${nexusHost} -u "\${NEXUS_USER}" --password-stdin
|
||||||
|
docker tag pfsdn:${VERSION} ${nexusImage}
|
||||||
|
docker push ${nexusImage}
|
||||||
|
docker rmi ${nexusImage} || true
|
||||||
|
docker rmi pfsdn:${VERSION} || true
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,6 +93,9 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
always {
|
||||||
|
sh "docker rmi pfsdn:${VERSION} || true"
|
||||||
|
}
|
||||||
success {
|
success {
|
||||||
cleanWs()
|
cleanWs()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue