Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile.multiStage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang AS builder
FROM golang:1.16.3 AS builder

WORKDIR /work
COPY . .
Expand Down
70 changes: 70 additions & 0 deletions Jenkinsfile-kustomize.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
pipeline {
agent {
kubernetes {
label 'jenkins-agent'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: dind
image: docker:18.09-dind
securityContext:
privileged: true
- name: docker
env:
- name: DOCKER_HOST
value: 127.0.0.1
image: docker:18.09
command:
- cat
tty: true
- name: tools
image: argoproj/argo-cd-ci-builder:v1.0.0
command:
- cat
tty: true
"""
}
}
stages {

stage('Build') {
environment {
DOCKERHUB_CREDS = credentials('dockerhub')
}
steps {
container('docker') {
// Build new image
sh "docker build -f Dockerfile.multiStage -t devopsws/go-server:${env.GIT_COMMIT} ."

// Publish new image
sh """
docker login --username $DOCKERHUB_CREDS_USR --password $DOCKERHUB_CREDS_PSW
docker push devopsws/go-server:${env.GIT_COMMIT}
"""
}
}
}

stage('Deploy E2E') {
environment {
GIT_CREDS = credentials('git')
}
steps {
container('tools') {
sh "git clone https://$GIT_CREDS_USR:$GIT_CREDS_PSW@github.com/devops-ws/learn-kustomize.git"
sh "git config --global user.email 'ci@ci.com'"

dir("learn-kustomize") {
sh "ls -ahl"
sh "kustomize edit set image devopsws/go-server:${env.GIT_COMMIT}"
sh "git commit -am 'Publish new version' && git push || echo 'no changes'"
}
}
}
}

}
}