29 changed files
vars | ||
argoDeploy.groovy | ||
build.groovy | ||
cloudBuild.groovy | ||
cloudflarePurgeCache.groovy | ||
deploy.groovy | ||
downloadKustomize.groovy | ||
gitMerge.groovy | ||
gitMergePipeline.groovy | ||
gitOpsK8sUpdate.groovy | ||
grype.groovy | ||
humanGate.groovy | ||
liquibaseStatus.groovy | ||
liquibaseUpdate.groovy | ||
loadScript.groovy | ||
parameterizedPipeline.groovy | ||
printEnv.groovy | ||
README.md | ||
solrReIndex.groovy | ||
terraformApply.groovy | ||
terraformInit.groovy | ||
terraformPlan.groovy | ||
terraformRefreshState.groovy | ||
terragruntApply.groovy | ||
terragruntInit.groovy | ||
terragruntPlan.groovy | ||
terragruntRefreshState.groovy | ||
tfsec.groovy | ||
trivy.groovy | ||
Jenkinsfile | ||
Add comment 1 Minus //
Add comment 2 Minus // Author: Hari Sekhon
Add comment 3 Minus // Date: 2021-09-01 14:07:59 +0100 (Wed, 01 Sep 2021)
Add comment 4 Minus //
Add comment 5 Minus // vim:ts=2:sts=2:sw=2:et
Add comment 6 Minus //
Add comment 7 Minus // https://github.com/HariSekhon/templates
Add comment 8 Minus //
Add comment 9 Minus // License: see accompanying Hari Sekhon LICENSE file
Add comment 10 Minus //
Add comment 11 Minus // If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
Add comment 12 Minus //
Add comment 13 Minus // https://www.linkedin.com/in/HariSekhon
Add comment 14 Minus //
Add comment 15 Minus
Add comment 16 Minus // Required Environment Variables to be set in environment{} section of Jenkinsfile, see top level Jenkinsfile template
Add comment 17 Minus //
Add comment 18 Minus // APP
Add comment 19 Minus // ENVIRONMENT
Add comment 20 Minus // ARGOCD_SERVER
Add comment 21 Minus // ARGOCD_AUTH_TOKEN
Add comment 22 Minus //
Add comment 23 Minus
Add comment 24 Minus def call(timeoutMinutes=10){
Add comment 25 Minus milestone ordinal: 100, label: "Milestone: Argo Deploy"
Add comment 26 Minus echo "Deploying app '$APP' via ArgoCD"
Add comment 27 Minus String deploymentLock = "Deploying ArgoCD - App '$APP', Environment: " + "$ENVIRONMENT".capitalize()
Add comment 28 Minus int timeoutSeconds = timeoutMinutes * 60
Add comment 29 Minus lock(resource: deploymentLock, inversePrecedence: true){
Add comment 30 Minus label 'ArgoCD Deploy'
Add comment 31 Minus container('argocd') {
Add comment 32 Minus timeout(time: timeoutMinutes, unit: 'MINUTES') {
Add comment 33 Minus sh """#!/bin/bash
Add comment 34 Minus set -euxo pipefail
Add comment 35 Minus argocd app sync "$APP" --grpc-web --force
Add comment 36 Minus argocd app wait "$APP" --grpc-web --timeout "$timeoutSeconds"
Add comment 37 Minus """
Add comment 38 Minus }
Add comment 39 Minus }
Add comment 40 Minus }
Add comment 41 Minus }
Add comment 42 Minus
Add comment 1 Minus //
Add comment 2 Minus // Author: Hari Sekhon
Add comment 3 Minus // Date: 2021-04-30 15:25:01 +0100 (Fri, 30 Apr 2021)
Add comment 4 Minus //
Add comment 5 Minus // vim:ts=2:sts=2:sw=2:et
Add comment 6 Minus //
Add comment 7 Minus // https://github.com/HariSekhon/Templates
Add comment 8 Minus //
Add comment 9 Minus // License: see accompanying Hari Sekhon LICENSE file
Add comment 10 Minus //
Add comment 11 Minus // If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
Add comment 12 Minus //
Add comment 13 Minus // https://www.linkedin.com/in/HariSekhon
Add comment 14 Minus //
Add comment 15 Minus
Add comment 16 Minus def call(){
Add comment 17 Minus echo "Building from branch '${env.GIT_BRANCH}' for '" + "${env.ENVIRONMENT}".capitalize() + "' Environment"
Add comment 18 Minus milestone ordinal: 10, label: "Milestone: Build"
Add comment 19 Minus echo "Running Job '${env.JOB_NAME}' Build ${env.BUILD_ID} on ${env.JENKINS_URL}"
Add comment 20 Minus timeout(time: 1, unit: 'MINUTES') {
Add comment 21 Minus sh script: 'env | sort', label: 'Environment'
Add comment 22 Minus }
Add comment 23 Minus retry(2){
Add comment 24 Minus timeout(time: 40, unit: 'MINUTES') {
Add comment 25 Minus // script from DevOps Bash tools repo
Add comment 26 Minus // external script needs to exist in the source repo, not the shared library repo
Add comment 27 Minus sh 'gcp_ci_build.sh'
Add comment 28 Minus }
Add comment 29 Minus }
Add comment 30 Minus }
Add comment 31 Minus
Add comment 1 Minus //
Add comment 2 Minus // Author: Hari Sekhon
Add comment 3 Minus // Date: 2021-09-01 12:50:03 +0100 (Wed, 01 Sep 2021)
Add comment 4 Minus //
Add comment 5 Minus // vim:ts=2:sts=2:sw=2:et
Add comment 6 Minus //
Add comment 7 Minus // https://github.com/HariSekhon/templates
Add comment 8 Minus //
Add comment 9 Minus // License: see accompanying Hari Sekhon LICENSE file
Add comment 10 Minus //
Add comment 11 Minus // If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
Add comment 12 Minus //
Add comment 13 Minus // https://www.linkedin.com/in/HariSekhon
Add comment 14 Minus //
Add comment 15 Minus
Add comment 16 Minus // Required Environment Variables to be set in environment{} section of Jenkinsfile, see top level Jenkinsfile template
Add comment 17 Minus //
Add comment 18 Minus // CLOUDSDK_CORE_PROJECT
Add comment 19 Minus // GCP_SERVICEACCOUNT_KEY
Add comment 20 Minus // GCR_REGISTRY
Add comment 21 Minus // DOCKER_IMAGE
Add comment 22 Minus // GIT_COMMIT - provided automatically by Jenkins
Add comment 23 Minus
Add comment 24 Minus def call(timeoutMinutes=60){
Add comment 25 Minus echo "Building from branch '${env.GIT_BRANCH}' for '" + "${env.ENVIRONMENT}".capitalize() + "' Environment"
Add comment 26 Minus milestone ordinal: 10, label: "Milestone: Build"
Add comment 27 Minus echo "Running Job '${env.JOB_NAME}' Build ${env.BUILD_ID} on ${env.JENKINS_URL}"
Add comment 28 Minus int timeoutSeconds = timeoutMinutes * 60
Add comment 29 Minus retry(2){
Add comment 30 Minus timeout(time: "$timeoutMinutes", unit: 'MINUTES') {
Add comment 31 Minus echo 'Running GCP CloudBuild'
Add comment 32 Minus withEnv(["TIMEOUT_SECONDS=$timeoutSeconds"]) {
Add comment 33 Minus sh '''#!/bin/bash
Add comment 34 Minus set -euxo pipefail
Add comment 35 Minus echo "$GCP_SERVICEACCOUNT_KEY" | base64 --decode > credentials.json
Add comment 36 Minus gcloud auth activate-service-account --key-file=credentials.json
Add comment 37 Minus rm -f credentials.json
Add comment 38 Minus if [ -z "$(gcloud container images list-tags "$DOCKER_IMAGE" --filter="tags:$GIT_COMMIT" --format=text)" ]; then
Add comment 39 Minus gcloud builds submit --project="$CLOUDSDK_CORE_PROJECT" --substitutions _REGISTRY="$GCR_REGISTRY",_IMAGE_VERSION="$GIT_COMMIT" --timeout=$TIMEOUT_SECONDS
Add comment 40 Minus fi
Add comment 41 Minus '''
Add comment 42 Minus }
Add comment 43 Minus }
Add comment 44 Minus }
Add comment 45 Minus }
Add comment 46 Minus
cloudflarePurgeCache.groovy
/vars/cloudflarePurgeCache.groovy-30/vars/cloudflarePurgeCache.groovy
Add comment 1 Minus //
Add comment 2 Minus // Author: Hari Sekhon
Add comment 3 Minus // Date: 2021-04-30 15:25:01 +0100 (Fri, 30 Apr 2021)
Add comment 4 Minus //
Add comment 5 Minus // vim:ts=2:sts=2:sw=2:et
Add comment 6 Minus //
Add comment 7 Minus // https://github.com/HariSekhon/Templates
Add comment 8 Minus //
Add comment 9 Minus // License: see accompanying Hari Sekhon LICENSE file
Add comment 10 Minus //
Add comment 11 Minus // If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
Add comment 12 Minus //
Add comment 13 Minus // https://www.linkedin.com/in/HariSekhon
Add comment 14 Minus //
Add comment 15 Minus
Add comment 16 Minus def call(){
Add comment 17 Minus String cloudflareCachePurgeLock = "Cloudflare Purge Cache - '" + "${env.ENVIRONMENT}".capitalize() + "' Environment"
Add comment 18 Minus echo "Acquiring Cloudflare Cache Purge Lock: $cloudflareCachePurgeLock"
Add comment 19 Minus lock(resource: cloudflareCachePurgeLock, inversePrecedence: true){
Add comment 20 Minus milestone ordinal: 110, label: "Milestone: Cloudflare Purge Cache"
Add comment 21 Minus retry(2){
Add comment 22 Minus timeout(time: 1, unit: 'MINUTES') {
Add comment 23 Minus // script from DevOps Bash tools repo
Add comment 24 Minus // external script needs to exist in the source repo, not the shared library repo
Add comment 25 Minus sh 'cloudflare_purge_cache.sh'
Add comment 26 Minus }
Add comment 27 Minus }
Add comment 28 Minus }
Add comment 29 Minus }
Add comment 30 Minus
Add comment 1 Minus //
Add comment 2 Minus // Author: Hari Sekhon
Add comment 3 Minus // Date: 2021-04-30 15:25:01 +0100 (Fri, 30 Apr 2021)
Add comment 4 Minus //
Add comment 5 Minus // vim:ts=2:sts=2:sw=2:et
Add comment 6 Minus //
Add comment 7 Minus // https://github.com/HariSekhon/Templates
Add comment 8 Minus //
Add comment 9 Minus // License: see accompanying Hari Sekhon LICENSE file
Add comment 10 Minus //
Add comment 11 Minus // If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
Add comment 12 Minus //
Add comment 13 Minus // https://www.linkedin.com/in/HariSekhon
Add comment 14 Minus //
Add comment 15 Minus
Add comment 16 Minus def call(){
Add comment 17 Minus echo "Deploying '" + "${env.ENVIRONMENT}".capitalize() + "' from branch '${env.GIT_BRANCH}'"
Add comment 18 Minus String deploymentLock = "Deploy K8s Apps - " + "${env.ENVIRONMENT}".capitalize() + " Environment"
Add comment 19 Minus echo "Acquiring Deployment Lock: $deploymentLock"
Add comment 20 Minus lock(resource: deploymentLock, inversePrecedence: true){
Add comment 21 Minus milestone ordinal: 30, label: "Milestone: Deploy"
Add comment 22 Minus retry(2){
Add comment 23 Minus timeout(time: 20, unit: 'MINUTES') {
Add comment 24 Minus // script from DevOps Bash tools repo
Add comment 25 Minus // external script needs to exist in the source repo, not the shared library repo
Add comment 26 Minus sh 'gcp_ci_k8s_deploy.sh'
Add comment 27 Minus }
Add comment 28 Minus }
Add comment 29 Minus }
Add comment 30 Minus }
Add comment 31 Minus
Add comment 1 Minus //
Add comment 2 Minus // Author: Hari Sekhon
Add comment 3 Minus // Date: 2021-09-01 11:57:48 +0100 (Wed, 01 Sep 2021)
Add comment 4 Minus //
Add comment 5 Minus // vim:ts=2:sts=2:sw=2:et
Add comment 6 Minus //
Add comment 7 Minus // https://github.com/HariSekhon/Templates
Add comment 8 Minus //
Add comment 9 Minus // License: see accompanying Hari Sekhon LICENSE file
Add comment 10 Minus //
Add comment 11 Minus // If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
Add comment 12 Minus //
Add comment 13 Minus // https://www.linkedin.com/in/HariSekhon
Add comment 14 Minus //
Add comment 15 Minus
Add comment 16 Minus // There is now a harisekhon/git-kustomize docker image to avoid re-downloading kustomize for every pipeline run and reuse docker image caching
Add comment 17 Minus //
Add comment 18 Minus // See top-level Jenkinsfile and adjacent gitOpsK8sUpdate.groovy
Add comment 19 Minus
Add comment 20 Minus def call(version='4.3.0'){
Add comment 21 Minus timeout(time: 2, unit: 'MINUTES') {
Add comment 22 Minus sh script: """#!/bin/bash
Add comment 23 Minus set -euxo pipefail
Add comment 24 Minus echo "Downloading Kustomize version $version"
Add comment 25 Minus curl -sSL -o /tmp/kustomize.\$\$.tgz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${version}/kustomize_v${version}_linux_amd64.tar.gz
Add comment 26 Minus tar zxvf /tmp/kustomize.\$\$.tgz kustomize -O > /tmp/kustomize.\$\$
Add comment 27 Minus chmod +x /tmp/kustomize.\$\$
Add comment 28 Minus mv -iv /tmp/kustomize.\$\$ /usr/local/bin/kustomize
Add comment 29 Minus """
Add comment 30 Minus }
Add comment 31 Minus }
Add comment 32 Minus
parameterizedPipeline.groovy
/vars/parameterizedPipeline.groovy/vars/parameterizedPipeline.groovy
terraformRefreshState.groovy
/vars/terraformRefreshState.groovy/vars/terraformRefreshState.groovy
terragruntRefreshState.groovy
/vars/terragruntRefreshState.groovy/vars/terragruntRefreshState.groovy