From 5e2d5a62dd319f51d7d5e73cc8634a6b74aa2d5c Mon Sep 17 00:00:00 2001 From: Hoid Date: Wed, 13 Jul 2022 13:34:47 -0400 Subject: [PATCH 1/2] Initial commit --- Jenkinsfile | 58 ++++++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ca75e2f..44369ca4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +library 'pipeline-utils@master' + pipeline { agent { kubernetes { @@ -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 { @@ -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://$GITHUB_CREDS_PSW@github.com/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 + ) + } } } } From 0294ed27157e060da760fc2f8e539f94939a60ea Mon Sep 17 00:00:00 2001 From: Hoid Date: Wed, 13 Jul 2022 13:42:02 -0400 Subject: [PATCH 2/2] Reduce ephemeral storage limits and requests --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 44369ca4..7449a309 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,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