|
| 1 | +#!/usr/bin/env groovy |
| 2 | +import groovy.time.* |
| 3 | + |
| 4 | +def ecr_repo_east = '597764168253.dkr.ecr.us-east-1.amazonaws.com' |
| 5 | +def ecr_repo_south = '597764168253.dkr.ecr.ap-south-1.amazonaws.com' |
| 6 | +def ecr_repo_southeast = '597764168253.dkr.ecr.ap-southeast-2.amazonaws.com' |
| 7 | +def aws_region = 'us-east-1' |
| 8 | +def app = '' /* the docker app build gets stored here */ |
| 9 | +def homer_image_name = "${ecr_repo_east}/homer-squidex" |
| 10 | +def upstream_image_name = "squidex/squidex" |
| 11 | +def upstream_image_tag = "4.5.1" |
| 12 | +def full_image_name = null |
| 13 | +def cluster = null |
| 14 | +def namespace = null |
| 15 | + |
| 16 | +pipeline { |
| 17 | + agent any |
| 18 | + options { |
| 19 | + disableConcurrentBuilds() |
| 20 | + } |
| 21 | + parameters { |
| 22 | + string(name: 'tag', description: 'The tag to deploy', defaultValue: 'latest') |
| 23 | + choice(name: 'cluster', choices: ['staging', 'production'], description: 'The Kubernetes Cluster to deploy to') |
| 24 | + choice(name: 'namespace', choices: ['content-dev', 'content-v1', 'content-v2'], description: 'The environment to deploy squidex to') |
| 25 | + } |
| 26 | + stages { |
| 27 | + stage('Checkout') { |
| 28 | + steps { |
| 29 | + script { |
| 30 | + git branch:'5.6_homer', credentialsId: 'jenkins-aws-user', url: 'https://github.com/LearnWithHomer/squidex' |
| 31 | + if (params.namespace == "content-v1"){ |
| 32 | + full_image_name = "${upstream_image_name}:${upstream_image_tag}" |
| 33 | + } |
| 34 | + full_image_name = "${homer_image_name}:${tag}" |
| 35 | + cluster = params.cluster |
| 36 | + namespace = params.namespace |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + stage('Update Kubernetes Deployment yaml'){ |
| 42 | + steps { |
| 43 | + script { |
| 44 | + deploymentName = homerKubernetes.getDeploymentName() |
| 45 | + replicas = homerKubernetes.getReplicaCount(cluster, namespace, deploymentName) |
| 46 | + homerKubernetes.updateDeploymentYaml(app, 'k8s/deployment.yaml') |
| 47 | + homerKubernetes.updateReplicaCount(replicas) |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + |
| 53 | + stage('Deploy'){ |
| 54 | + when { |
| 55 | + expression {deploy} |
| 56 | + } |
| 57 | + steps { |
| 58 | + script { |
| 59 | + homerKubernetes.deploy(namespace, cluster) |
| 60 | + homerKubernetes.deploy(namespace, cluster, 'k8s/service.yaml') //Create the service for the size |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments