Skip to content

Commit

Permalink
Merge pull request #247 from helxplatform/use-pipeline-utils
Browse files Browse the repository at this point in the history
Use pipeline-utils
  • Loading branch information
Hoid authored Jul 18, 2022
2 parents 57612d7 + 0294ed2 commit 87b374d
Showing 1 changed file with 19 additions and 43 deletions.
62 changes: 19 additions & 43 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library 'pipeline-utils@master'

pipeline {
agent {
kubernetes {
Expand All @@ -18,11 +20,11 @@ spec:
requests:
cpu: "512m"
memory: "1024Mi"
ephemeral-storage: "4Gi"
ephemeral-storage: "2Gi"
limits:
cpu: "1024m"
memory: "2048Mi"
ephemeral-storage: "8Gi"
ephemeral-storage: "2Gi"
command:
- /busybox/cat
tty: true
Expand Down Expand Up @@ -67,19 +69,10 @@ spec:
stages {
stage('Build') {
steps {
container(name: 'kaniko', shell: '/busybox/sh') {
sh '''#!/busybox/sh
echo "Build stage"
/kaniko/executor --dockerfile ./Dockerfile \
--context . \
--verbosity debug \
--no-push \
--destination $IMAGE_NAME:$TAG1 \
--destination $IMAGE_NAME:$TAG2 \
--destination $IMAGE_NAME:$TAG3 \
--destination $IMAGE_NAME:$TAG4 \
--tarPath image.tar
'''
script {
container(name: 'kaniko', shell: '/busybox/sh') {
kaniko.build("./Dockerfile", ["$IMAGE_NAME:$TAG1", "$IMAGE_NAME:$TAG2", "$IMAGE_NAME:$TAG3", "$IMAGE_NAME:$TAG4"])
}
}
}
post {
Expand All @@ -97,34 +90,17 @@ spec:
}
stage('Publish') {
steps {
container(name: 'crane', shell: '/busybox/sh') {
sh '''
echo "Publish stage"
echo "$DOCKERHUB_CREDS_PSW" | crane auth login -u $DOCKERHUB_CREDS_USR --password-stdin $REGISTRY
crane push image.tar $IMAGE_NAME:$TAG1
crane push image.tar $IMAGE_NAME:$TAG2
if [ $BRANCH_NAME == "develop" ]; then
crane push image.tar $IMAGE_NAME:$TAG3
elif [ $BRANCH_NAME == "master" ]; then
crane push image.tar $IMAGE_NAME:$TAG3
crane push image.tar $IMAGE_NAME:$TAG4
if [ $(git tag -l "$VERSION") ]; then
echo "ERROR: Tag with version $VERSION already exists! Exiting."
else
# Recover some things we've lost:
git config --global user.email "helx-dev@lists"
git config --global user.name "rencibuild rencibuild"
grep url .git/config
git checkout $BRANCH_NAME
# Set the tag
SHA=$(git log --oneline | head -1 | awk '{print $1}')
git tag $VERSION "$SHA"
git remote set-url origin https://[email protected]/helxplatform/dug.git
git push origin --tags
fi
fi
'''
script {
container(name: 'crane', shell: '/busybox/sh') {
def imageTagsPushAlways = ["$IMAGE_NAME:$TAG1", "$IMAGE_NAME:$TAG2"]
def imageTagsPushForDevelopBranch = ["$IMAGE_NAME:$TAG3"]
def imageTagsPushForMasterBranch = ["$IMAGE_NAME:$TAG4"]
image.publish(
imageTagsPushAlways,
imageTagsPushForDevelopBranch,
imageTagsPushForMasterBranch
)
}
}
}
}
Expand Down

0 comments on commit 87b374d

Please sign in to comment.