Pretty much following https://cloud.google.com/solutions/jenkins-on-container-engine-tutorial
gcloud projects create rubbish-cijug --set-as-default
and have to go to https://console.cloud.google.com/compute/instances?project=rubbish-cijug to enable billing for the new project and start compute engine
gcloud compute networks create rubbish-cijug --mode auto
gcloud container clusters create rubbish-cijug \
--network rubbish-cijug \
--scopes "https://www.googleapis.com/auth/projecthosting,storage-rw"
gcloud container clusters list
gcloud container clusters get-credentials rubbish-cijug
kubectl cluster-info
gcloud compute images create jenkins-home-image --source-uri https://storage.googleapis.com/solutions-public-assets/jenkins-cd/jenkins-home-v3.tar.gz
gcloud compute disks create jenkins-home --image jenkins-home-image --zone us-central1-a
kubectl create ns jenkins
PASSWORD=`openssl rand -base64 15`; echo "Your password is $PASSWORD"; sed -i.bak s#CHANGE_ME#$PASSWORD# jenkins/k8s/options
kubectl create secret generic jenkins --from-file=jenkins/k8s/options --namespace=jenkins
kubectl apply -f jenkins/k8s/
kubectl get pods --namespace jenkins
kubectl get services --namespace jenkins
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls.key -out /tmp/tls.crt -subj "/CN=jenkins/O=jenkins"
kubectl create secret generic tls --from-file=/tmp/tls.crt --from-file=/tmp/tls.key --namespace jenkins
kubectl apply -f jenkins/k8s/lb/ingress.yaml
kubectl describe ingress jenkins --namespace jenkins
- ansi color
- slack
- custom tools
- blue ocean
kubectl create secret generic docker-config-json --namespace=jenkins --from-file=$HOME/.docker/config.json
kubectl create ns staging
kubectl create ns production
kubectl apply -f jenkins/k8s/agent/jnlp.yaml
kubectl get pods --namespace=jenkins
Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins. Pipeline provides an extensible set of tools for modeling simple-to-complex delivery pipelines “as code” via the Pipeline DSL.
Typically, this “Pipeline as Code” would be written to a
Jenkinsfile
and checked into a project’s source control repository,
echo
sh
dir
stage
node
input
With a catch… It all has to be serializable.
- Since jenkins can pause the pipeline
try { ... } catch { ... } finally { ... }
if { ... } else { ... }
def blah()
"hello ${name}"
git
/svn
/cvs
timeout
tool
readFile
writeFile
catchError
waitUntil
retry
Plenty more at https://jenkins.io/doc/pipeline/steps/
slackSend
ansiColor
junit
scm
currentBuild
ENV
params
Can setup a repository to share groovy code between jobs
Pipeline as code!
NEW
adds pipeline
to your Jenkinsfile
- simple scala app
- just outputs the current version of app
- running this in kubernetes
- two different namespaces
- staging
- production
kubectl apply -f k8s/ --namespace staging
- update version files
- update k8s deployment image to version
- git tag
- build image
- push
Jenkins automatically discovers branches and pull requests. Creates jobs for each!
**But I have all these pull requests!**
- need to disable cert verification in the github settings!
- Run tests
- Release (build image and tag)
- Deploy to staging automatically
- Ask if we want to deploy to prod
- Deploy to production
lock
milestone
currentBuild.displayName = releasedVersion
timeout(time: 7, unit: "days") {
slackSend("Hey, authorize the deployment!")
milestone()
input("Promote to UAT?")
}
def preparedTerraformNode(Closure body) {
node("agent") {
sh "go get ..."
sh "go get ..."
sh "go get ..."
body()
}
}