2020-11-15 17:50:36 -05:00
|
|
|
properties(
|
|
|
|
[
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
node {
|
|
|
|
try {
|
|
|
|
stage('Checkout') {
|
|
|
|
checkout scm
|
|
|
|
|
|
|
|
//branch name from Jenkins environment variables
|
|
|
|
echo "My branch is: ${env.BRANCH_NAME}"
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build self-ci-base') {
|
|
|
|
sh '''
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
image_tag="$BRANCH_NAME"
|
|
|
|
[ "$image_tag" == "master" ] && image_tag=latest
|
|
|
|
|
|
|
|
# refresh our base image
|
2022-10-07 00:54:35 -04:00
|
|
|
docker pull docker.io/library/archlinux:latest
|
2020-11-15 17:50:36 -05:00
|
|
|
|
|
|
|
# build our image
|
|
|
|
docker build -t "moparisthebest/self-ci-base:$image_tag" .
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build self-ci-java') {
|
|
|
|
sh '''
|
|
|
|
set -ex
|
2020-11-23 00:00:29 -05:00
|
|
|
|
2020-11-15 17:50:36 -05:00
|
|
|
image_tag="$BRANCH_NAME"
|
|
|
|
[ "$image_tag" == "master" ] && image_tag=latest
|
|
|
|
|
|
|
|
cd java
|
|
|
|
|
|
|
|
# build our image
|
|
|
|
docker build -t "moparisthebest/self-ci-java:$image_tag" .
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Push to docker hub') {
|
|
|
|
sh '''
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
image_tag="$BRANCH_NAME"
|
|
|
|
[ "$image_tag" == "master" ] && image_tag=latest
|
|
|
|
|
|
|
|
# push our images, don't forget to docker login
|
|
|
|
docker push "moparisthebest/self-ci-base:$image_tag"
|
2020-11-23 00:00:29 -05:00
|
|
|
docker push "moparisthebest/self-ci-java:$image_tag"
|
2020-11-15 17:50:36 -05:00
|
|
|
'''
|
|
|
|
}
|
|
|
|
|
|
|
|
currentBuild.result = 'SUCCESS'
|
|
|
|
} catch (Exception err) {
|
|
|
|
currentBuild.result = 'FAILURE'
|
|
|
|
} finally {
|
|
|
|
stage('Email') {
|
|
|
|
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'admin.jenkins@moparisthebest.com', sendToIndividuals: true])
|
|
|
|
}
|
|
|
|
deleteDir()
|
|
|
|
}
|
|
|
|
}
|