This app is for demoing CI/CD in Jenkins
- The Coder’s repo at github.com/cmays20/springboot-helloworld-dispatch
- The Operations/GitOps repo at github.com/cmays20/springboot-helloworld-dispatch-gitops
Edit the Dispatchfile and replace the variable values at the top of the file with your user names for GitHub and DockerHub
Example:
// docker_user:: "<YOUR_DOCKERHUB_USERNAME>"
// github_user:: "<YOUR_GITHUB_USERNAME>"
docker_user:: "gregoryg"
github_user:: "gregoryg"
kubectl create namespace hello-world
kubectl label ns hello-world istio-injection=enabled
kubectl label ns hello-world ca.istio.io/override="true"
# Do not install if `dispatch` namespace exists
kubectl get ns dispatch
if [ $? -eq 1 ]; then
dispatch init --set global.prometheus.enabled=true --set global.prometheus.release=prometheus-kubeaddons --watch-namespace=dispatch
fi
kubectl -n dispatch get serviceaccount dispatch-sa
if [ $? -eq 1 ]; then
dispatch serviceaccount create dispatch-sa --namespace dispatch
fi
kubectl -n dispatch get secret dispatch-sa-basic-auth
if [ $? -eq 1 ]; then
dispatch login github --user ${GITHUB_USERNAME} --token ${GITHUB_TOKEN} --service-account dispatch-sa --namespace dispatch
fi
docker login
kubectl -n dispatch get secret dispatch-sa-docker-auth
if [ $? -eq 1 ]; then
dispatch login docker --service-account dispatch-sa --namespace dispatch
fi
dispatch gitops creds add https://github.com/${GITHUB_USERNAME}/springboot-helloworld-dispatch --username=${GITHUB_USERNAME} --token=${GITHUB_TOKEN} --namespace dispatch
This step creates the webhook in the Developers GitHub repository This may also be done in the Dispatch UI!
dispatch ci repository create --service-account dispatch-sa --namespace dispatch
dispatch gitops app create springboot-helloworld-dispatch \
--repository=https://github.com/${GITHUB_USERNAME}/springboot-helloworld-dispatch-gitops \
--service-account dispatch-sa \
--namespace dispatch
Edit index.html template
echo http://$(kubectl -n istio-system get svc istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[*].hostname}')/hello-world-dispatch
The script bin/install-springboot-cicd.sh can be generated from this document using
M-x org-babel-tangle
in Emacs, or running the following command on a system with
Emacs installed
emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "README.org")'