-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from helxplatform/use-pipeline-utils
Use pipeline-utils
- Loading branch information
Showing
1 changed file
with
19 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
library 'pipeline-utils@master' | ||
|
||
pipeline { | ||
agent { | ||
kubernetes { | ||
|
@@ -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 | ||
|
@@ -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://[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 | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|