├── parameters ├── ei │ └── ei-samples.json ├── is │ └── is-samples.json └── parameters.json ├── .gitignore ├── scripts ├── mi │ ├── intg │ │ ├── infra.json │ │ └── intg-deploy.sh │ └── deploy.sh ├── write-parameter-file.sh ├── os-level │ └── instance-shutdown ├── is │ ├── releases │ │ └── release_distribution.sh │ ├── intg │ │ ├── intg-deploy.sh │ │ └── infra.json │ └── deploy.sh ├── intg-test-deployment.sh ├── common-functions.sh ├── test-deployment.sh ├── ei │ └── deploy.sh ├── esb │ └── deploy.sh ├── ob │ └── deploy.sh ├── parameter-file-handler.sh ├── apim │ ├── intg │ │ ├── infra.json │ │ └── intg-deploy.sh │ └── deploy.sh ├── deployment-builder.sh ├── intg-test-executer.sh ├── deployment-handler.sh └── post-actions.sh ├── issue_template.md ├── kubernetes ├── product-deployment │ ├── scripts │ │ ├── deploy.sh │ │ ├── test.sh │ │ ├── extract-cluster-details.sh │ │ ├── cleanup.sh │ │ ├── validate-cluster-and-params.sh │ │ ├── testgrid-rds-cf.yaml │ │ └── create-database.sh │ ├── README.md │ └── main.jenkins └── manage-cluster │ ├── scripts │ ├── delete-cluster.sh │ ├── cluster-blueprint-template.yaml │ └── create-cluster.sh │ ├── README.md │ └── main.jenkins ├── vars ├── clean-aws-cfn-stack.sh ├── get-wum-uat-products.sh └── WUMUpdateVerifier.groovy ├── README.md ├── pull_request_template.md ├── LICENSE ├── ise2e.groovy ├── isintegration.groovy ├── integration.groovy └── main.groovy /parameters/ei/ei-samples.json: -------------------------------------------------------------------------------- 1 | { 2 | "KeyPairName": "testgrid-key", 3 | "Region": "us-east-1" 4 | } 5 | -------------------------------------------------------------------------------- /parameters/is/is-samples.json: -------------------------------------------------------------------------------- 1 | { 2 | "KeyPairName": "testgrid-key", 3 | "Region": "us-east-1" 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | #IDEA files 11 | *.iml 12 | *.ipr 13 | *.iws 14 | .idea/ 15 | 16 | # Mobile Tools for Java (J2ME) 17 | .mtj.tmp/ 18 | 19 | # Package Files # 20 | *.jar 21 | *.war 22 | *.nar 23 | *.ear 24 | *.zip 25 | *.tar.gz 26 | *.rar 27 | 28 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 29 | hs_err_pid* 30 | target 31 | -------------------------------------------------------------------------------- /scripts/mi/intg/infra.json: -------------------------------------------------------------------------------- 1 | { 2 | "jdk": 3 | [ 4 | { 5 | "name": "ADOPT_OPEN_JDK8", 6 | "file_name": "OpenJDK8U-jdk_x64_linux_hotspot_8u252b09" 7 | }, 8 | { 9 | "name": "CORRETTO_JDK8", 10 | "file_name": "amazon-corretto-8.252.09.1-linux-x64" 11 | }, 12 | { 13 | "name": "CORRETTO_JDK11", 14 | "file_name": "amazon-corretto-11.0.7.10.1-linux-x64" 15 | }, 16 | { 17 | "name": "CORRETTO_JDK17", 18 | "file_name": "amazon-corretto-17.0.5.8.1-linux-x64" 19 | }, 20 | { 21 | "name": "OPEN_JDK8", 22 | "file_name": "OpenJDK8U-jdk_x64_linux_8u275b01" 23 | }, 24 | { 25 | "name": "ADOPT_OPEN_JDK11", 26 | "file_name": "OpenJDK11U-jdk_x64_linux_hotspot_11.0.7_10" 27 | }, 28 | { 29 | "name": "ADOPT_OPEN_JDK17", 30 | "file_name": "OpenJDK17U-jdk_x64_linux_hotspot_17.0.5_8" 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /parameters/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "Parameters": { 3 | "AWSAccessKeyId": "", 4 | "AWSAccessKeySecret": "", 5 | "WUMUsername": "", 6 | "WUMPassword": "", 7 | "OperatingSystem": "", 8 | "JDK": "", 9 | "DB": "", 10 | "Product": "", 11 | "ProductVersion": "", 12 | "KeyPairName": "deployment-prod", 13 | "WSO2InstanceType": "t2.medium", 14 | "CertificateName": "wso2_testgrid", 15 | "DBUsername": "tgdbuser", 16 | "DBPassword": "", 17 | "DBAllocationStorage": "20", 18 | "DBInstanceType": "db.m5.large", 19 | "UniqueIdentifier": "", 20 | "StackName": "", 21 | "S3AccessKeyID": "", 22 | "S3SecretAccessKey": "", 23 | "Region": "us-east-2", 24 | "AMI": "ami-0c43f6c4aa82d8a9c", 25 | "CustomURL": "" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /issue_template.md: -------------------------------------------------------------------------------- 1 | **Description:** 2 | 3 | 4 | **Suggested Labels:** 5 | 6 | 7 | **Suggested Assignees:** 8 | 9 | 10 | **Affected Product Version:** 11 | 12 | **OS, DB, other environment details and versions:** 13 | 14 | **Steps to reproduce:** 15 | 16 | 17 | **Related Issues:** 18 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | productName=$1; 22 | ./kubernetes/product-deployment/scripts/"$productName"/deploy.sh 23 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | productName=$1; 22 | relativeFilePathTestFile=$2 23 | ./kubernetes/product-deployment/scripts/"$productName"/"test-$productName"/"$relativeFilePathTestFile" 24 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/extract-cluster-details.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | HOST_NAME=$(kubectl -n ingress-nginx get svc ingress-nginx-controller -o json | jq .status.loadBalancer.ingress[0].hostname) 22 | echo "$HOST_NAME" | tr -d '"' 23 | -------------------------------------------------------------------------------- /kubernetes/manage-cluster/scripts/delete-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | cat ./kubernetes/manage-cluster/scripts/cluster-blueprint-template.yaml | envsubst '${EKS_CLUSTER_NAME}' | envsubst '${EKS_CLUSTER_REGION}' > ./kubernetes/manage-cluster/scripts/cluster-blueprint.yaml 22 | eksctl get cluster --region ${EKS_CLUSTER_REGION} -n ${EKS_CLUSTER_NAME} || { echo 'Cluster does not exists.'; exit 1; } 23 | eksctl delete cluster -f ./kubernetes/manage-cluster/scripts/cluster-blueprint.yaml --wait 24 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | productName=$1; 22 | ./kubernetes/product-deployment/scripts/"$productName"/cleanup.sh 23 | echo "Scaling node group instances to zero." 24 | eksctl scale nodegroup --region ${EKS_CLUSTER_REGION} --cluster ${EKS_CLUSTER_NAME} --name ng-1 --nodes=0 25 | echo "Deleting RDS database." 26 | aws cloudformation delete-stack --region ${EKS_CLUSTER_REGION} --stack-name ${RDS_STACK_NAME} 27 | aws cloudformation wait stack-delete-complete --region ${EKS_CLUSTER_REGION} --stack-name ${RDS_STACK_NAME} 28 | -------------------------------------------------------------------------------- /kubernetes/manage-cluster/scripts/cluster-blueprint-template.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 2 | 3 | # WSO2 Inc. licenses this file to you under the Apache License, 4 | # Version 2.0 (the "License"); you may not use this file except 5 | # in compliance with the License. 6 | # You may obtain a copy of the License at 7 | 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | # Unless required by applicable law or agreed to in writing, 11 | # software distributed under the License is distributed on an 12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | # KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations 15 | # under the License. 16 | 17 | apiVersion: eksctl.io/v1alpha5 18 | kind: ClusterConfig 19 | 20 | metadata: 21 | name: ${EKS_CLUSTER_NAME} 22 | region: ${EKS_CLUSTER_REGION} 23 | 24 | availabilityZones: ["us-east-1a","us-east-1b"] 25 | 26 | nodeGroups: 27 | - name: ng-1 28 | instanceType: t3.micro 29 | desiredCapacity: 0 30 | minSize: 0 31 | maxSize: 1 32 | 33 | fargateProfiles: 34 | - name: fp-default 35 | selectors: 36 | # All workloads in the "default" Kubernetes namespace will be 37 | # scheduled onto Fargate: 38 | - namespace: default 39 | # All workloads in the "kube-system" Kubernetes namespace will be 40 | # scheduled onto Fargate: 41 | - namespace: kube-system 42 | -------------------------------------------------------------------------------- /scripts/write-parameter-file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | required_variables=3 22 | 23 | if [ $# -ne ${required_variables} ]; then 24 | log_error "${required_variables} variables required" 25 | exit 0 26 | else 27 | parameter_variable=${1} 28 | parameter_value=${2} 29 | parameter_file_path="${3}" 30 | contents="$(jq --arg parameter_variable "$parameter_variable" \ 31 | --arg parameter_value "$parameter_value" \ 32 | '.Parameters[$parameter_variable] = $parameter_value' $parameter_file_path)" && \ 33 | echo "${contents}" > $parameter_file_path 34 | fi 35 | -------------------------------------------------------------------------------- /vars/clean-aws-cfn-stack.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | while getopts a:s: flag 18 | do 19 | case "${flag}" in 20 | a) AWS_ACCESS_KEY_ID=${OPTARG};; 21 | s) AWS_SECRET_ACCESS_KEY=${OPTARG};; 22 | esac 23 | done 24 | 25 | ## cloudformation params ## 26 | status_filter='ROLLBACK_COMPLETE DELETE_FAILED CREATE_COMPLETE' 27 | 28 | ## date ## 29 | date_12H=$(date -u -d "-12 hour" +"%Y-%m-%dT%H:%M:%SZ") ### 12 HOURS ### 30 | 31 | echo $date_12H 32 | 33 | for region in us-east-1 us-east-2 us-west-1 us-west-2; 34 | do 35 | for f in `AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY aws cloudformation list-stacks --region $region --output text \ 36 | --stack-status-filter $status_filter \ 37 | --query "StackSummaries[?CreationTime < '${date_12H}'].{StackName:StackName}"` \ 38 | ; 39 | do 40 | echo "deleting stack --region $region --stack-name $f" 41 | AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY aws cloudformation delete-stack --region $region --stack-name $f 42 | done 43 | 44 | done 45 | -------------------------------------------------------------------------------- /scripts/os-level/instance-shutdown: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Required-Start: $local_fs 4 | # Required-Stop: $local_fs 5 | # Provides: Shutdown or Reboot Exec 6 | # Default-Start: 4 7 | # Default-Stop: 0 6 8 | # Description: Shutdown or Reboot 9 | ### END INIT INFO 10 | 11 | case "$1" in 12 | stop) 13 | instance="replace_by_instance" 14 | product="replace_by_product" 15 | version="replace_by_version" 16 | s3BucketLocation="replace_by_s3_bucket_location" 17 | instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id) 18 | declare -a logDirectories 19 | if [[ ${instance} == "puppetmaster" ]]; 20 | then 21 | logDirectories=('/var/log/') 22 | elif [[ ${product} == "wso2am" ]]; 23 | then 24 | logDirectories=('/usr/lib/wso2/'${product}'/'${version}'/'${product}'-'${version}'/repository/logs/' '/usr/lib/wso2/'${product}'/'${version}'/'${product}'-'${version}'/repository/conf/' '/var/log/') 25 | s3BucketLocation=${s3BucketLocation}-${instanceId} 26 | else 27 | logDirectories=('/usr/lib/wso2/'${product}'/'${version}'/'${product}'-'${version}'/repository/logs/' '/usr/lib/wso2/'${product}'/'${version}'/'${product}'-'${version}'/repository/conf/' '/usr/lib/wso2/'${product}'/'${version}'/'${product}'-'${version}'/repository/deployment/' '/var/log/') 28 | s3BucketLocation=${s3BucketLocation}-${instanceId} 29 | fi 30 | mkdir /tmp/upload-dir 31 | for dir in ${logDirectories[@]}; do 32 | if [ -d ${dir} ]; 33 | then 34 | cp -r ${dir} /tmp/upload-dir 35 | fi 36 | done 37 | tar -zvcf /tmp/${instanceId}.tar -P /tmp/upload-dir 38 | aws s3 cp /tmp/${instanceId}.tar s3://${s3BucketLocation}/ 39 | ;; 40 | esac 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /kubernetes/manage-cluster/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes product deployment pipeline 2 | 3 | Using TestGrid’s manage-cluster pipeline we are able to create or delete clusters for the deployment purposes. **Note**: when a cluster is running on AWS, a cost of 0.1 dollar/hour is incurred. Deleting the cluster takes about 15 minutes and creating takes about 30 minutes. It is best to schedule cluster creation and deletion jobs in cost-effective way. 4 | 5 | 6 | ## Jenkins version, blueocean version 7 | 8 | Jenkins:- Jenkins 2.319.3 9 | Blueocean Version:- 1.25.3 10 | 11 | ## Creating a cluster 12 | 13 | TestGrid supports creating a Kubernetes cluster in AWS. To create a Kubernetes cluster on AWS follow the steps given below: 14 | 15 | 1. Go to [TestGrid](https://testgrid.wso2.com/) 16 | 2. Go to TestGrid Dashboard. 17 | 3. Select ‘Kubernetes deployments’ folder. 18 | 4. Select ‘manage-cluster’ pipeline. 19 | 5. Click ‘Build with parameters’. 20 | 6. Tick ‘Create’ box in the pipeline UI and untick ‘Delete’ box. 21 | 7. Click ‘Build’ button. 22 | 23 | TestGrid supports only one Kubernetes cluster at a given time. If you try to create a new cluster on TestGrid when there is already a cluster running on AWS it will fail to create a cluster. You can use the same cluster to deploy your Kubernetes application. 24 | 25 | ## Deleting a cluster 26 | 27 | You are able to delete a Kubernetes cluster which was created by TestGrid. To delete the cluster follow the steps given below: 28 | 1. Go to [TestGrid](https://testgrid.wso2.com/) 29 | 2. Go to TestGrid Dashboard. 30 | 3. Select the ‘Kubernetes deployments’ folder. 31 | 4. Select ‘manage-cluster’ pipeline. 32 | 5. Click ‘Build with parameters’. 33 | 6. Tick Delete box in the pipeline UI and untick Create box. 34 | 7. Click ‘Build’ button. 35 | 36 | When the user performs the delete action, TestGrid will delete the Kubernetes cluster which was created in “Create a cluster” step. As we already know at a given time TestGrid supports only one Kubernetes cluster. A common use case for deleting the TestGrid Kubernetes cluster would be to save some cost when unused. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Testgrid Jenkins Library 2 | 3 | This repo contains the related pipeline code that is being used in the Jenkins TestGrid Pipeline. 4 | 5 | ## Jenkins version, blueocean version 6 | 7 | Jenkins:- Jenkins 2.319.3 8 | Blueocean Version:- 1.25.3 9 | 10 | ## Testgrid Jenkins Pipeline Variables 11 | 12 | 1. **product**- The WSO2 product that needs to be tested from TestGrid. 13 | Allowed Values- apim, is 14 | 2. **cfn_repo_url**- The WSO2 product CFN repo name. 15 | Allowed Value Format- 16 | 3. **product_version**- The product version that needs to be tested using testgrid. 17 | Allowed Value Format- 3.2.0 18 | 4. **product_deployment_region**- The region where the product stack is getting deployed. 19 | Allowed Values- us-east-2, us-east-1 20 | 5. **os_list**- The OS and its version. If there are multiple parameters, please add them by separating them by a ","(Comma). 21 | Allowed Values- CentOS7, Ubuntu1804 22 | 6. **jdk_list**- The JDK and its version. If there are multiple parameters, please add them by separating them by a ","(Comma). 23 | Allowed Values- OPEN_JDK8, ORACLE_JDK8 24 | 7. **database_list**- The Database type and its version. If there are multiple parameters, please add them by separating them by a ","(Comma). 25 | Allowed Values- MySQL-5.7, SQLServer-SE-15.00 26 | 8. **use_wum**- If using WUM this should be true. If using U2 this should be false. 27 | Allowed Values- Check or Un Check 28 | 9. **product_repository**- The product repo where the test scripts are existing. 29 | Allowed Value Format- 30 | 10. **product_test_branch**- The repo branch where the test script is existing. 31 | Allowed Values- product-scenarios-3.2.0 32 | 11. **product_test_script**- The location of the test script. 33 | Allowed Value Format- product-scenarios/test.sh 34 | 12. **use_staging**- If testing environment is staging be true. If using UAT this should be false. 35 | Allowed Values- Check or Un Check 36 | 37 | Please note all the allowed values are mentioned on the TestGrid pipeline documentation. The above values are the most frequently used values. 38 | 39 | ## step by step guide to on how to add this repo to a new pipeline 40 | 41 | Check the [TestGrid Pipeline Onboarding document](https://docs.google.com/document/d/13uwFCdMyDlJCC-Rd5dDWdxuR4tIrZyJhaXSN4n1XZqM/edit?usp=sharing) 42 | -------------------------------------------------------------------------------- /kubernetes/manage-cluster/scripts/create-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | isEmpty () { 22 | if [ ${#1} -ge 1 ]; 23 | then 24 | return 0; 25 | else 26 | return 1; 27 | fi; 28 | } 29 | 30 | isEmpty "${EKS_CLUSTER_NAME}"; 31 | flag=$? 32 | if [ $flag = 1 ]; 33 | then echo "EKS_CLUSTER_NAME environment variable is empty."; exit 1 34 | fi; 35 | 36 | isEmpty "${EKS_CLUSTER_REGION}"; 37 | flag=$? 38 | if [ $flag = 1 ]; 39 | then echo "EKS_CLUSTER_REGION environment variable is empty."; exit 1 40 | fi; 41 | 42 | isEmpty "${EKS_CLUSTER_NAME}"; 43 | flag=$? 44 | if [ $flag = 1 ]; 45 | then echo "EKS_CLUSTER_NAME environment variable is empty."; exit 1 46 | fi; 47 | 48 | 49 | cat ./kubernetes/manage-cluster/scripts/cluster-blueprint-template.yaml | envsubst '${EKS_CLUSTER_NAME}' | envsubst '${EKS_CLUSTER_REGION}' > ./kubernetes/manage-cluster/scripts/cluster-blueprint.yaml 50 | eksctl get cluster --region ${EKS_CLUSTER_REGION} -n ${EKS_CLUSTER_NAME} && echo "Cluster already exists" && exit 1 51 | eksctl create cluster -f ./kubernetes/manage-cluster/scripts/cluster-blueprint.yaml || { echo "Failed to create the cluster. Try to clean up the created resources." ; eksctl delete cluster --region="${EKS_CLUSTER_REGION}" --name="${EKS_CLUSTER_NAME}" || { echo "Failed to cleanup the resources using eksctl, trying to delete the cloudformation stacks." ; aws cloudformation delete-stack --region "${EKS_CLUSTER_REGION}" --stack-name "eksctl-${EKS_CLUSTER_NAME}-cluster"; aws cloudformation wait stack-delete-complete --region ${EKS_CLUSTER_REGION} --stack-name "eksctl-${EKS_CLUSTER_NAME}-cluster"; exit 1 ; } } 52 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/validate-cluster-and-params.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | isEmpty () { 22 | if [ ${#1} -ge 1 ]; 23 | then 24 | return 0; 25 | else 26 | return 1; 27 | fi; 28 | } 29 | 30 | workingdir=$(pwd) 31 | reldir=`dirname $0` 32 | cd $reldir 33 | 34 | 35 | isEmpty "${EKS_CLUSTER_NAME}"; 36 | flag=$? 37 | if [ $flag = 1 ]; 38 | then echo "EKS_CLUSTER_NAME environment variable is empty."; exit 1 39 | fi; 40 | 41 | isEmpty "${EKS_CLUSTER_REGION}"; 42 | flag=$? 43 | if [ $flag = 1 ]; 44 | then echo "EKS_CLUSTER_REGION environment variable is empty."; exit 1 45 | fi; 46 | 47 | isEmpty "${RDS_STACK_NAME}"; 48 | flag=$? 49 | if [ $flag = 1 ]; 50 | then echo "RDS_STACK_NAME environment variable is empty."; exit 1 51 | fi; 52 | 53 | isEmpty "${path_to_helm_folder}"; 54 | flag=$? 55 | if [ $flag = 1 ]; 56 | then echo "Path to helm folder is empty."; exit 1 57 | fi; 58 | 59 | isEmpty "${product_version}"; 60 | flag=$? 61 | if [ $flag = 1 ]; 62 | then echo "Product version is empty."; exit 1 63 | fi; 64 | 65 | isEmpty "${db_engine}"; 66 | flag=$? 67 | if [ $flag = 1 ]; 68 | then echo "DB engine value is empty."; exit 1 69 | fi; 70 | 71 | 72 | # Update kube config file. 73 | aws eks update-kubeconfig --region ${EKS_CLUSTER_REGION} --name ${EKS_CLUSTER_NAME} || { echo 'Failed to update cluster kube config.'; exit 1; } 74 | 75 | # Check whether a cluster exists. 76 | eksctl get cluster --region ${EKS_CLUSTER_REGION} -n ${EKS_CLUSTER_NAME} || { echo 'Cluster does not exists. Please create the cluster before deploying the applications.'; exit 1; } 77 | 78 | cd "$workingdir" 79 | -------------------------------------------------------------------------------- /scripts/is/releases/release_distribution.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 LLC. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | # Please Note that this is only for packs that are yet to be released in GA (testing with product distributions) 21 | Product='wso2is' 22 | ProductVersion='7.0.0' 23 | ProductDistribution='rc7' 24 | snapshot=0 # make it to 1 if you are testing for a snapshot version 25 | 26 | if [ $snapshot -eq 0 ] 27 | then 28 | # For released versions downloading from github 29 | ProductDistributionURL='https://github.com/wso2/product-is/releases/download/v'${ProductVersion}'-'${ProductDistribution}'/'${Product}'-'${ProductVersion}'-'${ProductDistribution}'.zip' 30 | else 31 | # For snapshots-downloading from jenkins 32 | ProductDistributionURL='https://wso2.org/jenkins/view/products/job/products/job/product-is/org.wso2.is$wso2is/lastSuccessfulBuild/artifact/org.wso2.is/'${Product}'/'${ProductVersion}'-'${ProductDistribution}'/'${Product}'-'${ProductVersion}'-'${ProductDistribution}'.zip' 33 | fi 34 | wget -O /etc/puppet/code/environments/production/modules/installers/files/${Product}-${ProductVersion}-${ProductDistribution}.zip ${ProductDistributionURL} 35 | pushd /etc/puppet/code/environments/production/modules/installers/files/ 36 | md5sum ${Product}-${ProductVersion}-${ProductDistribution}.zip 37 | unzip -q ${Product}-${ProductVersion}-${ProductDistribution}.zip 38 | rm -r ${Product}-${ProductVersion}.zip # remove if any existing packs 39 | mv ${Product}-${ProductVersion}-${ProductDistribution} ${Product}-${ProductVersion} 40 | zip -r ${Product}-${ProductVersion}.zip ${Product}-${ProductVersion}/ 41 | rm -rf ${Product}-${ProductVersion} 42 | rm ${Product}-${ProductVersion}-${ProductDistribution}.zip 43 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/testgrid-rds-cf.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 2 | 3 | # WSO2 Inc. licenses this file to you under the Apache License, 4 | # Version 2.0 (the "License"); you may not use this file except 5 | # in compliance with the License. 6 | # You may obtain a copy of the License at 7 | 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | # Unless required by applicable law or agreed to in writing, 11 | # software distributed under the License is distributed on an 12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | # KIND, either express or implied. See the License for the 14 | # specific language governing permissions and limitations 15 | # under the License. 16 | 17 | AWSTemplateFormatVersion: "2010-09-09" 18 | Parameters: 19 | pDbUser: 20 | Type: String 21 | pDbPass: 22 | Type: String 23 | pDbEngine: 24 | Type: String 25 | pDbVersion: 26 | Type: String 27 | pDbInstanceClass: 28 | Type: String 29 | AllowedValues: 30 | - db.t2.medium 31 | - db.t2.large 32 | - db.t2.xlarge 33 | - db.t2.2xlarge 34 | - db.t3.small 35 | - db.m3.medium 36 | - db.m3.large 37 | - db.m3.xlarge 38 | - db.m3.2xlarge 39 | - db.m4.large 40 | - db.m4.xlarge 41 | pProductTagName: 42 | Type: String 43 | 44 | Resources: 45 | TESTGRIDDB: 46 | Type: AWS::RDS::DBInstance 47 | Properties: 48 | MasterUsername: !Ref pDbUser 49 | MasterUserPassword: !Ref pDbPass 50 | Engine: !Ref pDbEngine 51 | EngineVersion: !Ref pDbVersion 52 | DBInstanceClass: !Ref pDbInstanceClass 53 | StorageType: gp2 54 | PubliclyAccessible: True 55 | AllocatedStorage: "20" 56 | DBInstanceIdentifier: testgrid-rds 57 | LicenseModel: 58 | !If [UseLicensedVersion, license-included, !Ref "AWS::NoValue"] 59 | Tags: 60 | - Key: name 61 | Value: !Ref pProductTagName 62 | MultiAZ: false 63 | BackupRetentionPeriod: 0 64 | 65 | Outputs: 66 | TestgridDBJDBCConnectionString: 67 | Description: JDBC connection string for the master database 68 | Value: !Join ["", [!GetAtt [TESTGRIDDB, Endpoint.Address]]] 69 | TestgridDBJDBCPort: 70 | Description: JDBC port 71 | Value: !Join ["", [!GetAtt [TESTGRIDDB, Endpoint.Port]]] 72 | 73 | Conditions: 74 | UseLicensedVersion: 75 | !Or [ 76 | !Equals [sqlserver, !Select [0, !Split ["-", !Ref pDbEngine]]], 77 | !Equals [oracle, !Select [0, !Split ["-", !Ref pDbEngine]]], 78 | ] 79 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes product deployment pipeline 2 | 3 | The pipeline can be used to deploy and test application in kubernetes cluster. 4 | 5 | ## Jenkins version, blueocean version 6 | 7 | Jenkins:- Jenkins 2.319.3 8 | Blueocean Version:- 1.25.3 9 | 10 | ## Kubernetes product deployment pipeline Variables 11 | 12 | ### Product Details 13 | 14 | 1. **product_name** - The name of the product to be deployed to the kubernetes cluster. 15 | Allowed values - [ apim ] 16 | 2. **product_version** - Product version to be deployed. 17 | 18 | ## Deployment Details 19 | 20 | 3. **deployment_script_repo_url** - Repository URL of the deployment scripts for the specific application. TestGrid expects a deploy.sh file and cleanup.sh file in the given repository. The deploy.sh script will be called by TestGrid. The deploy.sh file contains the scripts for deploying the helm charts, database preparation related commands etc. The cleanup.sh file will contain the necessary scripts to uninstall the product from the cluster. This cleanup.sh file will be called at the end of the testing by TestGrid. The product team will prepare this repository with necessary scripts for the deployment of their specific product. 21 | 4. **deployment_script_repo_branch** - Branch of the repository. 22 | 5. **db_engine** - TestGrid supports provisioning database. User can select different databases for the applications. Supported databases are MySql, Postgres, MSSQL and Oracle. Allowed values [ mysql, postgres, mssql, oracle ] 23 | 6. **db_version** - Database version. 24 | 7. **db_instance_class** - TestGrid will provision the database using AWS RDS. User can specify the instance type. Ex : db.t3.small 25 | 26 | ### Kubernetes Details 27 | 28 | 8. **kubernetes_repo_url** - Product’s helm chart repository. 29 | 9. **Kubernetes_repo_branch** - Branch of the helm chart repository. 30 | 10. **path_to_helm_folder** - Path to the helm folder in the repository directory structure. 31 | 11. **kubernetes_namespace** - The kubernetes cluster namespace name on which the application will be deployed. 32 | 33 | ### Testing Details 34 | 35 | 12. **product_testing_repo_url** - Contains the testing related scripts. 36 | 13. **product_testing_repo_branch** - Test repository branch. 37 | 14. **test_file_path** - Relative file path of the testing entrypoint bash file. 38 | 15. **service_startup_timeout** - Amount of time the TestGrid wait for the service to come alive. If all of the kubernetes become healthy within the specified time the TestGrid will start the testing by triggering the test.sh file. Otherwise pipeline will throw an error. 39 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/scripts/create-database.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | workingdir=$(pwd) 22 | reldir=`dirname $0` 23 | cd $reldir 24 | 25 | dbEngine="" 26 | if [ "${db_engine}" = "postgres" ]; 27 | then 28 | dbEngine="postgres" 29 | elif [ "${db_engine}" = "mysql" ]; 30 | then 31 | dbEngine="mysql" 32 | elif [ "${db_engine}" = "mssql" ]; 33 | then 34 | dbEngine="sqlserver-ex" 35 | elif [ "${db_engine}" = "oracle" ]; 36 | then 37 | dbEngine="oracle-se2" 38 | else 39 | echo "The specified DB engine not supported."; 40 | exit 1; 41 | fi; 42 | 43 | aws cloudformation create-stack \ 44 | --region ${EKS_CLUSTER_REGION} \ 45 | --stack-name ${RDS_STACK_NAME} \ 46 | --template-body file://testgrid-rds-cf.yaml \ 47 | --parameters ParameterKey=pDbUser,ParameterValue="${DB_USERNAME}" \ 48 | ParameterKey=pDbPass,ParameterValue="${DB_PASSWORD}" \ 49 | ParameterKey=pDbEngine,ParameterValue="$dbEngine" \ 50 | ParameterKey=pDbVersion,ParameterValue="${db_version}" \ 51 | ParameterKey=pDbInstanceClass,ParameterValue="${db_instance_class}" \ 52 | ParameterKey=pProductTagName,ParameterValue="${product_name}-${product_version}-testgrid-kubernetes-deployment" || { echo 'Failed to create RDS stack.'; exit 1; } 53 | 54 | # Wait for RDS DB to come alive. 55 | aws cloudformation wait stack-create-complete \ 56 | --region ${EKS_CLUSTER_REGION} \ 57 | --stack-name ${RDS_STACK_NAME} || { \ 58 | echo 'Failed to create stack. Fetching stack events. '; 59 | aws cloudformation describe-stack-events --region ${EKS_CLUSTER_REGION} --stack-name ${RDS_STACK_NAME} | jq -r '.StackEvents[] | select(.ResourceStatus=="CREATE_FAILED")' ; \ 60 | exit 1; } 61 | 62 | cd "$workingdir" 63 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Purpose 2 | > Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc. 3 | 4 | ## Goals 5 | > Describe the solutions that this feature/fix will introduce to resolve the problems described above 6 | 7 | ## Approach 8 | > Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here. 9 | 10 | ## User stories 11 | > Summary of user stories addressed by this change> 12 | 13 | ## Release note 14 | > Brief description of the new feature or bug fix as it will appear in the release notes 15 | 16 | ## Documentation 17 | > Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact 18 | 19 | ## Training 20 | > Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable 21 | 22 | ## Certification 23 | > Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why. 24 | 25 | ## Marketing 26 | > Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable 27 | 28 | ## Automation tests 29 | - Unit tests 30 | > Code coverage information 31 | - Integration tests 32 | > Details about the test cases and coverage 33 | 34 | ## Security checks 35 | - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes/no 36 | - Ran FindSecurityBugs plugin and verified report? yes/no 37 | - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes/no 38 | 39 | ## Samples 40 | > Provide high-level details about the samples related to this feature 41 | 42 | ## Related PRs 43 | > List any other related PRs 44 | 45 | ## Migrations (if applicable) 46 | > Describe migration steps and platforms on which migration has been tested 47 | 48 | ## Test environment 49 | > List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested 50 | 51 | ## Learning 52 | > Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem. -------------------------------------------------------------------------------- /scripts/intg-test-deployment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentName=$1 22 | productRepository=$2 23 | productTestBranch=$3 24 | productTestScript=$4 25 | currentScript=$(dirname $(realpath "$0")) 26 | 27 | deploymentDirectory="${WORKSPACE}/deployment/${deploymentName}" 28 | parameterFilePath="${deploymentDirectory}/parameters.json" 29 | testOutputDir="${deploymentDirectory}/outputs" 30 | 31 | source ${currentScript}/common-functions.sh 32 | 33 | productDirectoryLocation="" 34 | 35 | function cloneTestRepo(){ 36 | local githubUsername=$(extractParameters "GithubUserName" ${parameterFilePath}) 37 | local githubPassword=$(extractParameters "GithubPassword" ${parameterFilePath}) 38 | local cloneString=$(echo ${productRepository} | sed 's#https://#&'${githubUsername}':'${githubPassword}@'#') 39 | 40 | log_info "Cloning product repo to get test scripts" 41 | git -C ${deploymentDirectory} clone ${cloneString} --branch ${productTestBranch} 42 | if [[ $? != 0 ]]; 43 | then 44 | log_error "Testing repo clone failed! Please check if the Git credentials or the test repo name is correct." 45 | bash ${currentScript}/post-actions.sh ${deploymentName} 46 | exit 1 47 | else 48 | log_info "Cloning the test repo was successfull!" 49 | fi 50 | local repoName="$(basename ${productRepository} .git)" 51 | productDirectoryLocation="${deploymentDirectory}/${repoName}" 52 | } 53 | 54 | function deploymentTest(){ 55 | log_info "Creating output directory" 56 | if [ -d "${testOutputDir}" ]; then 57 | log_error "Output directory already exists. Removing the existing output directory." 58 | rm -r "${testOutputDir}" 59 | fi 60 | mkdir ${testOutputDir} 61 | log_info "Executing scenario tests!" 62 | bash ${currentScript}/intg-test-executer.sh "${deploymentDirectory}" "${testOutputDir}" 63 | if [[ $? != 0 ]]; 64 | then 65 | log_error "Executing post actions!" 66 | bash ${currentScript}/post-actions.sh ${deploymentName} 67 | exit 1 68 | else 69 | log_info "Test Execution Passed!" 70 | fi 71 | } 72 | 73 | function main(){ 74 | cloneTestRepo 75 | deploymentTest 76 | } 77 | 78 | main 79 | -------------------------------------------------------------------------------- /scripts/common-functions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | function extractParameters(){ 22 | local extract_parameter=$1 23 | local readFile=$2 24 | local expVal="" 25 | if [[ ${readFile} == *"json"* ]]; then 26 | expVal=$(jq -r --arg extract_parameter "$extract_parameter" '.Parameters[$extract_parameter]' $readFile) 27 | elif [[ ${readFile} == *"properties"* ]]; then 28 | expVal=$(cat ${readFile} | grep "${extract_parameter}" | cut -d'=' -f2) 29 | fi 30 | echo $expVal 31 | } 32 | 33 | function updateJsonFile(){ 34 | local key=${1} 35 | local value=${2} 36 | local jsonFile=${3} 37 | local tmp=$(mktemp) 38 | local contents="$(jq --arg k "$key" --arg v "$value" '.Parameters[$k] = $v' $jsonFile)" && \ 39 | echo "${contents}" > $jsonFile 40 | } 41 | 42 | # Get the output links of the Stack into a file 43 | function getCfnOutput(){ 44 | local stackName=${1} 45 | local region=${2} 46 | log_info "Getting outputs from deployed stack ${stackName}" 47 | 48 | stackDescription=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${region}) 49 | stackOutputs=$(echo ${stackDescription} | jq ".Stacks[].Outputs") 50 | readarray -t outputsArray < <(echo ${stackOutputs} | jq -c '.[]') 51 | } 52 | 53 | # Wrting the output links of the Stack into a file 54 | function writePropertiesFile(){ 55 | for output in "${outputsArray[@]}"; do 56 | outputKey=$(jq -r '.OutputKey' <<< "$output") 57 | outputValue=$(jq -r '.OutputValue' <<< "$output") 58 | outputEntry="${outputKey}=${outputValue}" 59 | echo "${outputEntry}" >> ${outputFile} 60 | done 61 | } 62 | 63 | # Wrting the output links of the Stack into a file 64 | function writeJsonFile(){ 65 | local writeFile=$1 66 | local writeParamFileLocation="${WORKSPACE}/scripts/write-parameter-file.sh" 67 | for output in "${outputsArray[@]}"; do 68 | outputKey=$(jq -r '.OutputKey' <<< "$output") 69 | outputValue=$(jq -r '.OutputValue' <<< "$output") 70 | outputEntry="${outputKey}=${outputValue}" 71 | bash ${writeParamFileLocation} ${outputKey} ${outputValue} ${writeFile} 72 | done 73 | } 74 | 75 | # Logging functions 76 | function log_info() { 77 | local string=$@ 78 | echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')][INFO]: ${string}" >&1 79 | } 80 | 81 | function log_error() { 82 | local string=$@ 83 | echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')][ERROR]: ${string}. Exiting !" >&1 84 | } 85 | -------------------------------------------------------------------------------- /scripts/test-deployment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentName=$1 22 | productRepository=$2 23 | productTestBranch=$3 24 | productTestScript=$4 25 | currentScript=$(dirname $(realpath "$0")) 26 | 27 | deploymentDirectory="${WORKSPACE}/deployment/${deploymentName}" 28 | parameterFilePath="${deploymentDirectory}/parameters.json" 29 | testOutputDir="${deploymentDirectory}/outputs" 30 | 31 | source ${currentScript}/common-functions.sh 32 | 33 | productDirectoryLocation="" 34 | 35 | function cloneTestRepo(){ 36 | local githubUsername=$(extractParameters "GithubUserName" ${parameterFilePath}) 37 | local githubPassword=$(extractParameters "GithubPassword" ${parameterFilePath}) 38 | local cloneString=$(echo ${productRepository} | sed 's#https://#&'${githubUsername}':'${githubPassword}@'#') 39 | 40 | log_info "Cloning product repo to get test scripts" 41 | git -C ${deploymentDirectory} clone ${cloneString} --branch ${productTestBranch} 42 | if [[ $? != 0 ]]; 43 | then 44 | log_error "Testing repo clone failed! Please check if the Git credentials or the test repo name is correct." 45 | bash ${currentScript}/post-actions.sh ${deploymentName} 46 | exit 1 47 | else 48 | log_info "Cloning the test repo was successfull!" 49 | fi 50 | local repoName="$(basename ${productRepository} .git)" 51 | productDirectoryLocation="${deploymentDirectory}/${repoName}" 52 | } 53 | 54 | function deploymentTest(){ 55 | log_info "Creating output directory" 56 | if [ -d "${testOutputDir}" ]; then 57 | log_error "Output directory already exists. Removing the existing output directory." 58 | rm -r "${testOutputDir}" 59 | fi 60 | mkdir ${testOutputDir} 61 | log_info "Executing scenario tests!" 62 | local scriptDir="${productDirectoryLocation}/${productTestScript}" 63 | local scriptDirPath=$(dirname ${scriptDir}) 64 | cd ${scriptDirPath} 65 | source ${productDirectoryLocation}/${productTestScript} --input-dir "${deploymentDirectory}" --output-dir "${testOutputDir}" 66 | if [ ${MVNSTATE} -gt 0 ]; 67 | then 68 | log_error "Test Execution Failed with exit code ${MVNSTATE}" 69 | log_error "Extracting logs and exiting!" 70 | bash ${currentScript}/post-actions.sh ${deploymentName} 71 | exit 1 72 | else 73 | log_info "Test Execution Passed!" 74 | fi 75 | } 76 | 77 | function main(){ 78 | cloneTestRepo 79 | deploymentTest 80 | } 81 | 82 | main 83 | -------------------------------------------------------------------------------- /scripts/ei/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentName=$1; shift 22 | cloudformationFileLocations=("$@") 23 | 24 | deploymentDirectory="${WORKSPACE}/deployment/${deploymentName}" 25 | parameterFilePath="${deploymentDirectory}/parameters.json" 26 | outputFile="${deploymentDirectory}/deployment.properties" 27 | currentScript=$(dirname $(realpath "$0")) 28 | 29 | source ${currentScript}/../common-functions.sh 30 | 31 | stackName=$(extractParameters "StackName" ${parameterFilePath}) 32 | tempStackName=${stackName} 33 | for cloudformationFileLocation in ${cloudformationFileLocations[@]} 34 | do 35 | parameterFilePath="${deploymentDirectory}/parameters.json" 36 | 37 | region=$(extractParameters "Region" ${parameterFilePath}) 38 | updateJsonFile "StackName" ${stackName} ${parameterFilePath} 39 | 40 | log_info "Deploying ${stackName}" 41 | aws cloudformation deploy \ 42 | --stack-name ${stackName} \ 43 | --template-file $cloudformationFileLocation \ 44 | --parameter-overrides file://${parameterFilePath} \ 45 | --capabilities CAPABILITY_NAMED_IAM \ 46 | --region ${region} 47 | 48 | # When the CFN YAML has issues this will terminate the flow. 49 | if [[ $? != 0 ]]; 50 | then 51 | log_error "CloudFormation deployment error occurred!" 52 | aws cloudformation describe-stack-events --stack-name ${stackName} --region ${region} | jq -r '.StackEvents[] | select(.ResourceStatus=="CREATE_FAILED")' 53 | bash ${currentScript}/../post-actions.sh ${deploymentName} 54 | exit 1 55 | fi 56 | 57 | # When the Deployment has issues this will terminate the flow 58 | stackStatus=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${region} | jq -r '.Stacks[0].StackStatus') 59 | if [[ ${stackStatus} == "CREATE_COMPLETE" ]]; 60 | then 61 | log_info "Stack:${stackName} creation was successfull!" 62 | else 63 | log_error "Stack:${stackName} creation failed! Error:${stackStatus}" 64 | bash ${currentScript}/../post-actions.sh ${deploymentName} 65 | exit 1 66 | fi 67 | 68 | # Get the deployment outputs to an array 69 | getCfnOutput ${stackName} ${region} 70 | 71 | # When there are multiple deployments then the CFNs are dependant to each other 72 | # Therefore adding the single outputs to the JSON parameter file as well 73 | if [[ ${#cloudformationFileLocations[@]} -gt 1 ]]; 74 | then 75 | ## use the common file to execute the function 76 | writeJsonFile ${parameterFilePath} 77 | fi 78 | 79 | writePropertiesFile 80 | done 81 | -------------------------------------------------------------------------------- /scripts/esb/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentName=$1; shift 22 | cloudformationFileLocations=("$@") 23 | 24 | deploymentDirectory="${WORKSPACE}/deployment/${deploymentName}" 25 | parameterFilePath="${deploymentDirectory}/parameters.json" 26 | outputFile="${deploymentDirectory}/deployment.properties" 27 | currentScript=$(dirname $(realpath "$0")) 28 | 29 | source ${currentScript}/../common-functions.sh 30 | 31 | stackName=$(extractParameters "StackName" ${parameterFilePath}) 32 | tempStackName=${stackName} 33 | for cloudformationFileLocation in ${cloudformationFileLocations[@]} 34 | do 35 | parameterFilePath="${deploymentDirectory}/parameters.json" 36 | 37 | region=$(extractParameters "Region" ${parameterFilePath}) 38 | updateJsonFile "StackName" ${stackName} ${parameterFilePath} 39 | 40 | log_info "Deploying ${stackName}" 41 | aws cloudformation deploy \ 42 | --stack-name ${stackName} \ 43 | --template-file $cloudformationFileLocation \ 44 | --parameter-overrides file://${parameterFilePath} \ 45 | --capabilities CAPABILITY_NAMED_IAM \ 46 | --region ${region} 47 | 48 | # When the CFN YAML has issues this will terminate the flow. 49 | if [[ $? != 0 ]]; 50 | then 51 | log_error "CloudFormation deployment error occurred!" 52 | aws cloudformation describe-stack-events --stack-name ${stackName} --region ${region} | jq -r '.StackEvents[] | select(.ResourceStatus=="CREATE_FAILED")' 53 | bash ${currentScript}/../post-actions.sh ${deploymentName} 54 | exit 1 55 | fi 56 | 57 | # When the Deployment has issues this will terminate the flow 58 | stackStatus=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${region} | jq -r '.Stacks[0].StackStatus') 59 | if [[ ${stackStatus} == "CREATE_COMPLETE" ]]; 60 | then 61 | log_info "Stack:${stackName} creation was successfull!" 62 | else 63 | log_error "Stack:${stackName} creation failed! Error:${stackStatus}" 64 | bash ${currentScript}/../post-actions.sh ${deploymentName} 65 | exit 1 66 | fi 67 | 68 | # Get the deployment outputs to an array 69 | getCfnOutput ${stackName} ${region} 70 | 71 | # When there are multiple deployments then the CFNs are dependant to each other 72 | # Therefore adding the single outputs to the JSON parameter file as well 73 | if [[ ${#cloudformationFileLocations[@]} -gt 1 ]]; 74 | then 75 | ## use the common file to execute the function 76 | writeJsonFile ${parameterFilePath} 77 | fi 78 | 79 | writePropertiesFile 80 | done 81 | -------------------------------------------------------------------------------- /scripts/mi/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentName=$1; shift 22 | cloudformationFileLocations=("$@") 23 | 24 | deploymentDirectory="${WORKSPACE}/deployment/${deploymentName}" 25 | parameterFilePath="${deploymentDirectory}/parameters.json" 26 | outputFile="${deploymentDirectory}/deployment.properties" 27 | currentScript=$(dirname $(realpath "$0")) 28 | 29 | source ${currentScript}/../common-functions.sh 30 | 31 | stackName=$(extractParameters "StackName" ${parameterFilePath}) 32 | tempStackName=${stackName} 33 | for cloudformationFileLocation in ${cloudformationFileLocations[@]} 34 | do 35 | parameterFilePath="${deploymentDirectory}/parameters.json" 36 | 37 | region=$(extractParameters "Region" ${parameterFilePath}) 38 | updateJsonFile "StackName" ${stackName} ${parameterFilePath} 39 | 40 | log_info "Deploying ${stackName}" 41 | aws cloudformation deploy \ 42 | --stack-name ${stackName} \ 43 | --template-file $cloudformationFileLocation \ 44 | --parameter-overrides file://${parameterFilePath} \ 45 | --capabilities CAPABILITY_NAMED_IAM \ 46 | --region ${region} 47 | 48 | # When the CFN YAML has issues this will terminate the flow. 49 | if [[ $? != 0 ]]; 50 | then 51 | log_error "CloudFormation deployment error occurred!" 52 | aws cloudformation describe-stack-events --stack-name ${stackName} --region ${region} | jq -r '.StackEvents[] | select(.ResourceStatus=="CREATE_FAILED")' 53 | bash ${currentScript}/../post-actions.sh ${deploymentName} 54 | exit 1 55 | fi 56 | 57 | # When the Deployment has issues this will terminate the flow 58 | stackStatus=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${region} | jq -r '.Stacks[0].StackStatus') 59 | if [[ ${stackStatus} == "CREATE_COMPLETE" ]]; 60 | then 61 | log_info "Stack:${stackName} creation was successfull!" 62 | else 63 | log_error "Stack:${stackName} creation failed! Error:${stackStatus}" 64 | bash ${currentScript}/../post-actions.sh ${deploymentName} 65 | exit 1 66 | fi 67 | 68 | # Get the deployment outputs to an array 69 | getCfnOutput ${stackName} ${region} 70 | 71 | # When there are multiple deployments then the CFNs are dependant to each other 72 | # Therefore adding the single outputs to the JSON parameter file as well 73 | if [[ ${#cloudformationFileLocations[@]} -gt 1 ]]; 74 | then 75 | ## use the common file to execute the function 76 | writeJsonFile ${parameterFilePath} 77 | fi 78 | 79 | writePropertiesFile 80 | done 81 | -------------------------------------------------------------------------------- /scripts/ob/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentName=$1; shift 22 | cloudformationFileLocations=("$@") 23 | 24 | deploymentDirectory="${WORKSPACE}/deployment/${deploymentName}" 25 | parameterFilePath="${deploymentDirectory}/parameters.json" 26 | outputFile="${deploymentDirectory}/deployment.properties" 27 | currentScript=$(dirname $(realpath "$0")) 28 | 29 | source ${currentScript}/../common-functions.sh 30 | 31 | stackName=$(extractParameters "StackName" ${parameterFilePath}) 32 | tempStackName=${stackName} 33 | for cloudformationFileLocation in ${cloudformationFileLocations[@]} 34 | do 35 | parameterFilePath="${deploymentDirectory}/parameters.json" 36 | 37 | region=$(extractParameters "Region" ${parameterFilePath}) 38 | updateJsonFile "StackName" ${stackName} ${parameterFilePath} 39 | 40 | log_info "Deploying ${stackName}" 41 | aws cloudformation deploy \ 42 | --stack-name ${stackName} \ 43 | --template-file $cloudformationFileLocation \ 44 | --parameter-overrides file://${parameterFilePath} \ 45 | --capabilities CAPABILITY_NAMED_IAM \ 46 | --region ${region} 47 | 48 | stackCreating=true 49 | while [ ${stackCreating} = true ] 50 | do 51 | stackStatus=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${region} | jq -r '.Stacks[0].StackStatus') 52 | if [[ "${stackStatus}" == "CREATE_IN_PROGRESS" ]]; 53 | then 54 | log_info "Stack ${stackName} is still getting created" 55 | sleep 60 #1min sleep until recheck 56 | else 57 | stackCreating=false 58 | fi 59 | done 60 | 61 | # When the Deployment has issues this will terminate the flow 62 | if [[ ${stackStatus} == "CREATE_COMPLETE" ]]; 63 | then 64 | log_info "Stack:${stackName} creation was successfull!" 65 | else 66 | log_error "Stack:${stackName} creation failed!" 67 | ## Get all the failed events 68 | aws cloudformation describe-stack-events --stack-name ${stackName} --region ${region} | jq -r '.StackEvents[] | select(.ResourceStatus=="CREATE_FAILED")' 69 | bash ${currentScript}/../post-actions.sh ${deploymentName} 70 | exit 1 71 | fi 72 | 73 | # Get the deployment outputs to an array 74 | getCfnOutput ${stackName} ${region} 75 | 76 | # When there are multiple deployments then the CFNs are dependant to each other 77 | # Therefore adding the single outputs to the JSON parameter file as well 78 | if [[ ${#cloudformationFileLocations[@]} -gt 1 ]]; 79 | then 80 | ## use the common file to execute the function 81 | writeJsonFile ${parameterFilePath} 82 | fi 83 | 84 | writePropertiesFile 85 | done 86 | -------------------------------------------------------------------------------- /scripts/parameter-file-handler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | product=$1 22 | productVersion=$2 23 | updateLevel=$3 24 | source ${currentScript}/common-functions.sh 25 | 26 | originalParameteFilePath="${WORKSPACE}/parameters/parameters.json" 27 | 28 | testType=$(extractParameters "TestType" ${parameterFilePath}) 29 | 30 | osArray=(`echo ${os_list} | sed 's/,/\n/g'`) 31 | jdkArray=(`echo ${jdk_list} | sed 's/,/\n/g'`) 32 | dbArray=(`echo ${database_list} | sed 's/,/\n/g'`) 33 | 34 | function generateRandomString(){ 35 | tr -dc A-Za-z0-9 > ${outputFile} 102 | } 103 | 104 | function addCommonVariables(){ 105 | writeCommonVariables "S3OutputBucketLocation" "S3OutputBucketLocation" true 106 | writeCommonVariables "Product" "Product" true 107 | writeCommonVariables "ProductVersion" "ProductVersion" true 108 | writeCommonVariables "WUMUsername" "WUMUsername" true 109 | writeCommonVariables "WUMPassword" "WUMPassword" true 110 | writeCommonVariables "GithubUserName" "GithubUserName" true 111 | writeCommonVariables "GithubPassword" "GithubPassword" true 112 | writeCommonVariables "ProductRepository" "ProductRepository" true 113 | writeCommonVariables "ProductTestBranch" "ProductTestBranch" true 114 | writeCommonVariables "ProductTestScriptLocation" "ProductTestScriptLocation" true 115 | writeCommonVariables "S3AccessKeyID" "s3accessKey" true 116 | writeCommonVariables "S3SecretAccessKey" "s3secretKey" true 117 | writeCommonVariables "TESTGRID_EMAIL_PASSWORD" "testgridEmailPassword" true 118 | writeCommonVariables "CustomURL" "CustomURL" true 119 | writeCommonVariables "UpdateType" "UpdateType" true 120 | writeCommonVariables "TestType" "TestType" true 121 | writeCommonVariables "SurefireReportDir" "SurefireReportDir" true 122 | } 123 | 124 | function main(){ 125 | changeCommonLogPath 126 | cloudformationValidation 127 | cloudformationDeployment 128 | addCommonVariables 129 | } 130 | 131 | main 132 | -------------------------------------------------------------------------------- /scripts/post-actions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------------------- 3 | # Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # WSO2 Inc. licenses this file to you under the Apache License, 6 | # Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | # -------------------------------------------------------------------------------------- 20 | 21 | deploymentDirectory="${WORKSPACE}/deployment/$1" 22 | parameterFilePath="${deploymentDirectory}/parameters.json" 23 | currentScript=$(dirname $(realpath "$0")) 24 | source ${currentScript}/common-functions.sh 25 | 26 | stackName=$(extractParameters "StackName" ${parameterFilePath}) 27 | region=$(extractParameters "Region" ${parameterFilePath}) 28 | testType=$(extractParameters "TestType" ${parameterFilePath}) 29 | S3OutputBucketLocation=$(extractParameters "S3OutputBucketLocation" ${parameterFilePath}) 30 | outputDirectory="${deploymentDirectory}/outputs" 31 | testLogsUploadLocation="s3://${S3OutputBucketLocation}/test-execution-logs" 32 | stackAvailable=false 33 | 34 | function uploadTestLogs(){ 35 | log_info "The test executer logs will be uploaded to S3 Bucket." 36 | log_info "Upload location: ${testLogsUploadLocation}" 37 | ### Debugging logs for hashana@wso2.com's logging not uploaded issue 38 | echo "1. ${WORKSPACE}" 39 | echo "2. ${parameterFilePath}" 40 | echo "3. ${outputDirectory}" 41 | echo "4. ${deploymentDirectory}" 42 | echo "5. ${testLogsUploadLocation}" 43 | #### 44 | aws s3 cp ${outputDirectory} ${testLogsUploadLocation} --recursive --quiet 45 | if [[ $? != 0 ]]; 46 | then 47 | log_error "Error occured when uploading Test executer logs" 48 | else 49 | log_info "Test executer logs are uploaded successfully!" 50 | fi 51 | } 52 | 53 | function validateDeleteStack(){ 54 | local stackName=${1} 55 | local region=${2} 56 | local stackStatus=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${region} 2> /dev/null | jq -r '.Stacks[0].StackStatus') 57 | if [[ ${stackStatus} == "CREATE_COMPLETE" || ${stackStatus} == "CREATE_FAILED" || ${stackStatus} == "ROLLBACK_IN_PROGRESS" || ${stackStatus} == "ROLLBACK_COMPLETE" ]]; 58 | then 59 | echo true 60 | else 61 | echo false 62 | fi 63 | } 64 | 65 | function deleteStack(){ 66 | log_info "Deleting the stacks after testing and uploading the logs..." 67 | declare -A stackData=() 68 | while IFS= read -r -d '' file; do 69 | local stackName=$(extractParameters "StackName" ${file}) 70 | local stackRegion=$(extractParameters "Region" ${file}) 71 | stackData[$stackName]=$stackRegion 72 | done < <(find ${deploymentDirectory} -maxdepth 1 -type f -name '*.json' -print0 ) 73 | 74 | for stackName in "${!stackData[@]}" 75 | do 76 | log_info "Checking stack status of ${stackName} before deleting..." 77 | stackAvailable=$(validateDeleteStack ${stackName} ${stackData[$stackName]}) 78 | if [ "${stackAvailable}" = true ]; 79 | then 80 | log_info "Stack ${stackName} is available. Proceeding to delete!" 81 | log_info "Deleting the stack: ${stackName} that is in the ${stackData[$stackName]} region" 82 | aws cloudformation delete-stack \ 83 | --stack-name ${stackName} \ 84 | --region ${stackData[$stackName]} 85 | if [[ $? != 0 ]]; 86 | then 87 | log_error "AWS Stack: ${stackName} deletion failed!" 88 | else 89 | local stackDeleted=false 90 | while [ ${stackDeleted} = false ] 91 | do 92 | stackStatus=$(aws cloudformation describe-stacks --stack-name ${stackName} --region ${stackData[$stackName]} 2> /dev/null | jq -r '.Stacks[0].StackStatus') 93 | if [[ "${stackStatus}" == "DELETE_IN_PROGRESS" ]]; 94 | then 95 | log_info "Still deleting the stack ${stackName}" 96 | # Test cannot end before deleting the entire stack becase when archiving the logs 97 | # the instance logs should be available on the S3 bucket. Therefore sleeping till 98 | # the stack fully gets deleted. 99 | sleep 60 #1min sleep 100 | else 101 | # If command fails that means the stack doesn't exist(already deleted) 102 | log_info "Stack ${stackName} deletion completed!" 103 | stackDeleted=true 104 | fi 105 | done 106 | fi 107 | else 108 | log_error "Stack ${stackName} that is in ${stackData[$stackName]} region is not available" 109 | fi 110 | done 111 | } 112 | 113 | function main(){ 114 | # # Check if test logs are already uploaded 115 | local s3DirList=$(aws s3 ls ${testLogsUploadLocation}/) 116 | if [[ "${s3DirList}" == "" ]]; 117 | then 118 | deleteStack 119 | if [[ "${testType}" != "intg" ]]; 120 | then 121 | uploadTestLogs 122 | fi 123 | else 124 | log_info "Logs are already uploaded to S3" 125 | fi 126 | } 127 | 128 | main 129 | -------------------------------------------------------------------------------- /scripts/is/intg/infra.json: -------------------------------------------------------------------------------- 1 | { 2 | "jdk": 3 | [ 4 | { 5 | "name": "ADOPT_OPEN_JDK8", 6 | "file_name": "OpenJDK8U-jdk_x64_linux_hotspot_8u252b09" 7 | }, 8 | { 9 | "name": "CORRETTO_JDK8", 10 | "file_name": "amazon-corretto-8.252.09.1-linux-x64" 11 | }, 12 | { 13 | "name": "CORRETTO_JDK11", 14 | "file_name": "amazon-corretto-11.0.7.10.1-linux-x64" 15 | }, 16 | { 17 | "name": "CORRETTO_JDK17", 18 | "file_name": "amazon-corretto-17.0.5.8.1-linux-x64" 19 | }, 20 | { 21 | "name": "OPEN_JDK8", 22 | "file_name": "OpenJDK8U-jdk_x64_linux_8u275b01" 23 | }, 24 | { 25 | "name": "ADOPT_OPEN_JDK11", 26 | "file_name": "OpenJDK11U-jdk_x64_linux_hotspot_11.0.7_10" 27 | }, 28 | { 29 | "name": "ADOPT_OPEN_JDK17", 30 | "file_name": "OpenJDK17U-jdk_x64_linux_hotspot_17.0.5_8" 31 | }, 32 | { 33 | "name": "ADOPT_OPEN_JDK21", 34 | "file_name": "OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13" 35 | }, 36 | { 37 | "name": "ADOPT_OPEN_JDK11_ARM", 38 | "file_name": "OpenJDK11U-jdk_aarch64_linux_11.0.7_10" 39 | }, 40 | { 41 | "name": "ADOPT_OPEN_JDK17_ARM", 42 | "file_name": "OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.5_8" 43 | }, 44 | { 45 | "name": "ADOPT_OPEN_JDK21_ARM", 46 | "file_name": "OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.2_13" 47 | } 48 | ], 49 | "jdbc": 50 | [ 51 | { 52 | "name": "db2-se", 53 | "file_name": "db2jcc4", 54 | "driver": "com.ibm.db2.jcc.DB2Driver", 55 | "database": [ 56 | { 57 | "name": "WSO2IDENTITY_DB", 58 | "url": "jdbc:db2://DB_HOST:50000/WSO2IDENTITY_DB:retrieveMessagesFromServerOnGetMessage=true;", 59 | "username": "DB_USERNAME", 60 | "password": "DB_PASSWORD" 61 | }, 62 | { 63 | "name": "WSO2SHARED_DB", 64 | "url": "jdbc:db2://DB_HOST:50000/WSO2SHARED_DB:retrieveMessagesFromServerOnGetMessage=true;", 65 | "username": "DB_USERNAME", 66 | "password": "DB_PASSWORD" 67 | } 68 | ], 69 | "validation_query": "SELECT 1 FROM SYSIBM.SYSDUMMY1" 70 | }, 71 | { 72 | "name": "mysql", 73 | "file_name": "mysql-connector-java-8.0.28", 74 | "driver": "com.mysql.jdbc.Driver", 75 | "database": 76 | [ 77 | { 78 | "name": "WSO2IDENTITY_DB", 79 | "url": "jdbc:mysql://DB_HOST:3306/WSO2IDENTITY_DB?autoReconnect=true&useSSL=false", 80 | "username": "DB_USERNAME", 81 | "password": "DB_PASSWORD" 82 | }, 83 | { 84 | "name": "WSO2SHARED_DB", 85 | "url": "jdbc:mysql://DB_HOST:3306/WSO2SHARED_DB?autoReconnect=true&useSSL=false", 86 | "username": "DB_USERNAME", 87 | "password": "DB_PASSWORD" 88 | } 89 | ], 90 | "validation_query": "SELECT 1" 91 | }, 92 | { 93 | "name": "mariadb", 94 | "file_name": "mariadb-java-client-3.5.1", 95 | "driver": "org.mariadb.jdbc.Driver", 96 | "database": [ 97 | { 98 | "name": "WSO2IDENTITY_DB", 99 | "url": "jdbc:mysql://DB_HOST:3306/WSO2IDENTITY_DB?permitMysqlScheme&autoReconnect=true&useSSL=false", 100 | "username": "DB_USERNAME", 101 | "password": "DB_PASSWORD" 102 | }, 103 | { 104 | "name": "WSO2SHARED_DB", 105 | "url": "jdbc:mysql://DB_HOST:3306/WSO2SHARED_DB?permitMysqlScheme&autoReconnect=true&useSSL=false", 106 | "username": "DB_USERNAME", 107 | "password": "DB_PASSWORD" 108 | } 109 | ], 110 | "validation_query": "SELECT 1" 111 | }, 112 | { 113 | "name": "postgres", 114 | "file_name": "postgresql-42.2.14", 115 | "driver": "org.postgresql.Driver", 116 | "database": 117 | [ 118 | { 119 | "name": "WSO2IDENTITY_DB", 120 | "url": "jdbc:postgresql://DB_HOST:5432/WSO2IDENTITY_DB", 121 | "username": "DB_USERNAME", 122 | "password": "DB_PASSWORD" 123 | }, 124 | { 125 | "name": "WSO2SHARED_DB", 126 | "url": "jdbc:postgresql://DB_HOST:5432/WSO2SHARED_DB", 127 | "username": "DB_USERNAME", 128 | "password": "DB_PASSWORD" 129 | } 130 | ], 131 | "validation_query": "SELECT 1; COMMIT" 132 | }, 133 | { 134 | "name": "sqlserver-se", 135 | "file_name": "mssql-jdbc-10.2.0.jre8", 136 | "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver", 137 | "database": 138 | [ 139 | { 140 | "name": "WSO2IDENTITY_DB", 141 | "url": "jdbc:sqlserver://DB_HOST:1433;databaseName=WSO2IDENTITY_DB;SendStringParametersAsUnicode=false;encrypt=false", 142 | "username": "DB_USERNAME", 143 | "password": "DB_PASSWORD" 144 | }, 145 | { 146 | "name": "WSO2SHARED_DB", 147 | "url": "jdbc:sqlserver://DB_HOST:1433;databaseName=WSO2SHARED_DB;SendStringParametersAsUnicode=false;encrypt=false", 148 | "username": "DB_USERNAME", 149 | "password": "DB_PASSWORD" 150 | } 151 | ], 152 | "validation_query": "SELECT 1; COMMIT" 153 | }, 154 | { 155 | "name": "oracle-se2", 156 | "file_name": "ojdbc8", 157 | "driver": "oracle.jdbc.OracleDriver", 158 | "database": 159 | [ 160 | { 161 | "name": "WSO2IDENTITY_DB", 162 | "url": "jdbc:oracle:thin:@DB_HOST:1521/WSO2IDENTITY_DB", 163 | "username": "DB_USERNAME", 164 | "password": "DB_PASSWORD" 165 | }, 166 | { 167 | "name": "WSO2SHARED_DB", 168 | "url": "jdbc:oracle:thin:@DB_HOST:1521/WSO2SHARED_DB", 169 | "username": "DB_USERNAME", 170 | "password": "DB_PASSWORD" 171 | } 172 | ], 173 | "validation_query": "SELECT 1 FROM DUAL" 174 | }, 175 | { 176 | "name": "oracle-se2-cdb", 177 | "file_name": "ojdbc8", 178 | "driver": "oracle.jdbc.OracleDriver", 179 | "database": 180 | [ 181 | { 182 | "name": "WSO2IDENTITY_DB", 183 | "url": "jdbc:oracle:thin:@DB_HOST:1521/WSO2IDENTITY_DB", 184 | "username": "DB_USERNAME", 185 | "password": "DB_PASSWORD" 186 | }, 187 | { 188 | "name": "WSO2SHARED_DB", 189 | "url": "jdbc:oracle:thin:@DB_HOST:1521/WSO2SHARED_DB", 190 | "username": "DB_USERNAME", 191 | "password": "DB_PASSWORD" 192 | } 193 | ], 194 | "validation_query": "SELECT 1 FROM DUAL" 195 | } 196 | ] 197 | } 198 | -------------------------------------------------------------------------------- /vars/get-wum-uat-products.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | #Defined the output file path locations in testgrid home 19 | HEADER_ACCEPT="Accept: application/json" 20 | CONFIG_FILE_UAT=${CONFIG_FILE_UAT} 21 | CONFIG_FILE_LIVE=${CONFIG_FILE_LIVE} 22 | RESPONSE_TIMESTAMP=${RESPONSE_TIMESTAMP} 23 | RESPONSE_PRODUCT=${RESPONSE_PRODUCT} 24 | PRODUCT_LIST=${PRODUCT_LIST} 25 | RESPONSE_CHANNEL=${RESPONSE_CHANNEL} 26 | CHANNEL_LIST=${CHANNEL_LIST} 27 | JOB_LIST=${JOB_LIST} 28 | PRODUCT_ID=${PRODUCT_ID} 29 | PRODUCT_ID_LIST=${PRODUCT_ID_LIST} 30 | 31 | #Generating access token for WUM Live environment to get the latest live synced timestamp 32 | createAccessTokenLive() { 33 | echo "Generating Access Token for Live" 34 | uri="https://gateway.api.cloud.wso2.com/token" 35 | #echo "Calling URI (POST): " ${uri} 36 | curl -s -X POST -H "Content-Type:application/x-www-form-urlencoded" \ 37 | -H "Authorization:Basic ${WUM_APPKEY_LIVE}" \ 38 | -d "grant_type=password&username=${OS_USERNAME}&password=${OS_PASSWORD}" "${uri}" \ 39 | --output "${CONFIG_FILE_LIVE}" 40 | live_access_token=$( jq -r ".access_token" $CONFIG_FILE_LIVE ) 41 | } 42 | 43 | #Generating access token for WUM UAT environment to get the product list in UAT 44 | createAccessTokenUAT() { 45 | echo "Generating Access Token for UAT" 46 | uri="https://gateway.api.cloud.wso2.com/token" 47 | #echo "Calling URI (POST): " ${uri} 48 | curl -s -X POST -H "Content-Type:application/x-www-form-urlencoded" \ 49 | -H "Authorization:Basic ${WUM_APPKEY_UAT}" \ 50 | -d "grant_type=password&username=${OS_USERNAME}&password=${OS_PASSWORD}" "${uri}" \ 51 | --output "${CONFIG_FILE_UAT}" 52 | 53 | #get only the access token value from the json response 54 | uat_access_token=$( jq -r ".access_token" $CONFIG_FILE_UAT ) 55 | } 56 | 57 | #Get timestamp by calling to WUM Live environment to get the latest live synced timestamp 58 | getTimestampLive() { 59 | echo "GET Timestamp in Live" 60 | uri="https://api.updates.wso2.com/updates/3.0.0/timestamps/latest" 61 | #echo "Calling URI (GET): " ${uri} 62 | curl -s -X GET -H "${HEADER_ACCEPT}" -H "Authorization:Bearer ${live_access_token}" "${uri}" --output "${RESPONSE_TIMESTAMP}" 63 | #get only the timestamp value from the json response 64 | live_timestamp=$( jq -r ".timestamp" $RESPONSE_TIMESTAMP ) 65 | 66 | # stdout live timestamp will be retrieved from WUMUpdateVerifier.groovy 67 | echo $live_timestamp 68 | } 69 | 70 | #Get timestamp by calling to WUM UAT environment to get the latest live synced timestamp 71 | getTimestampUAT() { 72 | echo "GET Timestamp in UAT" 73 | uri="https://gateway.api.cloud.wso2.com/t/wso2umuat/updates/3.0.0/timestamps/latest" 74 | #echo "Calling URI (GET): " ${uri} 75 | curl -s -X GET -H "${HEADER_ACCEPT}" -H "Authorization:Bearer ${uat_access_token}" "${uri}" --output "${RESPONSE_TIMESTAMP}" 76 | #get only the timestamp value from the json response 77 | uat_timestamp=$( jq -r ".timestamp" $RESPONSE_TIMESTAMP ) 78 | 79 | # stdout uat timestamp will be retrieved from WUMUpdateVerifier.groovy 80 | echo $uat_timestamp 81 | } 82 | 83 | #Get the product list in WUM UAT environment 84 | getProductList() { 85 | echo "GET Product List in UAT" 86 | uri="https://gateway.api.cloud.wso2.com/t/wso2umuat/updates/3.0.0/products/${live_timestamp}" 87 | #echo "Calling URI (GET): " ${uri} 88 | curl -s -X GET -H "${HEADER_ACCEPT}" -H "Authorization:Bearer ${uat_access_token}" "${uri}" --output "${RESPONSE_PRODUCT}" 89 | 90 | for row in $(cat "${RESPONSE_PRODUCT}" | jq -r '.[] | @base64'); do 91 | _jq() { 92 | echo ${row} | base64 --decode | jq -r ${1} 93 | } 94 | #get the product-name and product-version values from the json response 95 | list=$(_jq '."product-name"','."product-version"') 96 | echo $list >> $PRODUCT_LIST 97 | done 98 | 99 | echo "======== WUM Updated Product List ========" 100 | cat $PRODUCT_LIST 101 | 102 | 103 | if [ -s "$PRODUCT_LIST" ] 104 | then 105 | echo "There are WUM updated product packs in UAT." 106 | else 107 | echo "There is/are no updated product packs for the given timestamp in UAT. Hence Skipping the process." 108 | exit 0 109 | fi 110 | } 111 | 112 | #Get the available channel list for each product from WUM UAT environment 113 | getChannelList() { 114 | echo "GET Channel list for each product" 115 | TEST_TYPE_INTG="INTG" 116 | 117 | while IFS= read -r line; do 118 | list=$line 119 | set -- $list 120 | product=$1 121 | version=$2 122 | 123 | #Passing each product and version to Channel GET endpoint by reading the output file - $PRODUCT_LIST 124 | uri="https://gateway.api.cloud.wso2.com/t/wso2umuat/channels/3.0.0/user/$product/$version" 125 | curl -s -X GET -H "${HEADER_ACCEPT}" -H "Authorization:Bearer ${uat_access_token}" "${uri}" --output "${RESPONSE_CHANNEL}" 126 | jq -r '.channels[]' "${RESPONSE_CHANNEL}" > "${CHANNEL_LIST}" 127 | while IFS= read -r line; do 128 | allchannel=$line 129 | set -- $allchannel 130 | channel=$1 131 | 132 | if [ $product = "wso2is" ]; then 133 | product_folder="product-is" 134 | prod_short="is" 135 | elif [ $product = "wso2am" ]; then 136 | product_folder="product-apim" 137 | prod_short="apim" 138 | elif [ $product = "wso2ei" ]; then 139 | product_folder="product-ei" 140 | prod_short="ei" 141 | elif [ $product = "wso2esb" ]; then 142 | product_folder="product-esb" 143 | prod_short="esb" 144 | elif [ $product = "wso2mi" ]; then 145 | product_folder="product-mi" 146 | prod_short="mi" 147 | elif [ $product = "wso2-obam" ]; then 148 | product_folder="product-ob" 149 | prod_short="ob" 150 | elif [ $product = "wso2-obkm" ]; then 151 | product_folder="product-ob" 152 | prod_short="ob" 153 | elif [ $product = "wso2-obiam" ]; then 154 | product_folder="product-ob" 155 | prod_short="ob" 156 | else 157 | echo "[WARNING] $product needs to be onboarded and added to testgrid-jenkins-library/vars/get-wum-uat-products.sh" 158 | fi 159 | echo $product_folder/$prod_short"-"$version"-scenario-testgrid-pipeline" >> $JOB_LIST 160 | 161 | done < "$CHANNEL_LIST" 162 | done < "$PRODUCT_LIST" 163 | 164 | echo "======== Jenkins Job Names ========" 165 | cat $JOB_LIST 166 | } 167 | 168 | #Get the product updated ID list for each product from WUM UAT environment 169 | getProductIdList(){ 170 | echo "GET Product Id List" 171 | uri="https://gateway.api.cloud.wso2.com/t/wso2umuat/updates/3.0.0/list/${live_timestamp}" 172 | curl -s -X GET -H "${HEADER_ACCEPT}" -H "Authorization:Bearer ${uat_access_token}" "${uri}" --output "${PRODUCT_ID}" 173 | #get the update-no values from the json response 174 | for row in $(cat "${PRODUCT_ID}" | jq -r '.[] | @base64'); do 175 | _jq() { 176 | echo ${row} | base64 --decode | jq -r ${1} 177 | } 178 | list=$(_jq '."update-no"') 179 | echo $list >> $PRODUCT_ID_LIST 180 | done 181 | 182 | echo "======== WUM Updated product numbers ========" 183 | cat $PRODUCT_ID_LIST 184 | 185 | } 186 | 187 | args=$1 188 | 189 | if [[ -z $args ]]; then 190 | createAccessTokenLive 191 | createAccessTokenUAT 192 | getTimestampLive 193 | getProductList 194 | getChannelList 195 | getProductIdList 196 | else 197 | case $args in 198 | --get-live-timestamp) 199 | createAccessTokenLive 200 | getTimestampLive 201 | ;; 202 | --get-uat-timestamp) 203 | createAccessTokenUAT 204 | getTimestampUAT 205 | ;; 206 | --get-job-list) 207 | live_timestamp=$2 208 | createAccessTokenUAT 209 | getProductList 210 | getChannelList 211 | getProductIdList 212 | ;; 213 | *) 214 | echo "Invalid argument. Please try again." 215 | esac 216 | fi 217 | -------------------------------------------------------------------------------- /vars/WUMUpdateVerifier.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | // The pipeline should reside in a call block 20 | def call() { 21 | pipeline { 22 | 23 | pipeline { 24 | agent { 25 | node { 26 | label "master" 27 | } 28 | } 29 | 30 | environment { 31 | PWD = pwd() 32 | OS_USERNAME = credentials('OS_USERNAME') 33 | OS_PASSWORD = credentials('OS_PASSWORD') 34 | WUM_APPKEY_UAT = credentials('WUM_APPKEY_UAT') 35 | WUM_APPKEY_LIVE = credentials('WUM_APPKEY_LIVE') 36 | JOB_CONFIG_YAML = "job-config.yaml" 37 | JOB_CONFIG_YAML_PATH = "${PWD}/${JOB_CONFIG_YAML}" 38 | CONFIG_FILE_UAT = "${WORKSPACE}/WUM_LOGS/config-uat.txt" 39 | CONFIG_FILE_LIVE = "${WORKSPACE}/WUM_LOGS/config-live.txt" 40 | RESPONSE_TIMESTAMP = "${WORKSPACE}/WUM_LOGS/response-timestamp.txt" 41 | RESPONSE_PRODUCT = "${WORKSPACE}/WUM_LOGS/response-product.txt" 42 | PRODUCT_LIST = "${WORKSPACE}/WUM_LOGS/product-list.txt" 43 | RESPONSE_CHANNEL = "${WORKSPACE}/WUM_LOGS/response-channel.txt" 44 | CHANNEL_LIST = "${WORKSPACE}/WUM_LOGS/channel-list.txt" 45 | JOB_LIST = "${WORKSPACE}/WUM_LOGS/job-list.txt" 46 | UPDATENO_LIST = "${WORKSPACE}/WUM_LOGS/updateNo-list.txt" 47 | PRODUCT_ID = "${WORKSPACE}/WUM_LOGS/product-id.txt" 48 | PRODUCT_ID_LIST = "${WORKSPACE}/WUM_LOGS/product-id-list.txt" 49 | SCENARIO_BUILD_URL = "https://testgrid.wso2.com/job/WUM/job/Scenario-Tests/" 50 | SCENARIOS_REPOSITORY = "https://github.com/wso2/testgrid-jenkins-library" 51 | } 52 | 53 | stages { 54 | stage('Preparation') { 55 | steps { 56 | script { 57 | sh """ 58 | echo ${JOB_CONFIG_YAML_PATH} 59 | echo ' TEST_TYPE: ${TEST_TYPE}' >> ${JOB_CONFIG_YAML_PATH} 60 | cd ${WORKSPACE} 61 | rm -rf WUM_LOGS 62 | mkdir WUM_LOGS 63 | cd ${WORKSPACE}/WUM_LOGS 64 | git clone -b main ${SCENARIOS_REPOSITORY} 65 | cd ${WORKSPACE}/WUM_LOGS/testgrid-jenkins-library/vars 66 | ls 67 | chmod +x get-wum-uat-products.sh 68 | """ 69 | 70 | def live_ts = sh(script: '${WORKSPACE}/WUM_LOGS/testgrid-jenkins-library/vars/get-wum-uat-products.sh --get-live-timestamp', returnStdout: true).split("\r?\n")[2] 71 | def uat_ts = sh(script: '${WORKSPACE}/WUM_LOGS/testgrid-jenkins-library/vars/get-wum-uat-products.sh --get-uat-timestamp', returnStdout: true).split("\r?\n")[2] 72 | 73 | echo "uat timestamp: ${uat_ts} | live timestamp: ${live_ts}" 74 | 75 | if ( "${uat_ts}" == "${live_ts}" ){ 76 | echo "There are no updated product packs for the given timestamp in UAT. Hence Skipping the process." 77 | currentBuild.result='SUCCESS' 78 | return 79 | } 80 | sh """ 81 | sh ${WORKSPACE}/WUM_LOGS/testgrid-jenkins-library/vars/get-wum-uat-products.sh --get-job-list ${live_ts} 82 | """ 83 | 84 | } 85 | 86 | } 87 | } 88 | 89 | stage('parallel-run') { 90 | steps { 91 | 92 | script { 93 | try { 94 | def wumJobs = [:] 95 | FILECONTENT = readFile "${JOB_LIST}" 96 | sh """ 97 | cd ${WORKSPACE} 98 | rm -rf sucessresult.html failresult.html 99 | touch sucessresult.html failresult.html 100 | """ 101 | def jobNamesArray = FILECONTENT.split('\n') 102 | for (line in jobNamesArray) { 103 | String jobName = line; 104 | wumJobs["job:" + jobName] = { 105 | def result = build(job: jobName, propagate: false).result 106 | if (result == 'SUCCESS') { 107 | def output = jobName + " - " + result + "
" 108 | sh "echo '$output' >> ${WORKSPACE}/sucessresult.html " 109 | 110 | } else if (result == 'FAILURE') { 111 | def output = jobName + " - " + result + "
" 112 | sh "echo '$output' >> ${WORKSPACE}/failresult.html " 113 | 114 | } else if (result == 'UNSTABLE') { 115 | def output = jobName + " - " + result + "
" 116 | sh "echo '$output' >> ${WORKSPACE}/failresult.html " 117 | } 118 | 119 | }; 120 | } 121 | parallel wumJobs 122 | 123 | } catch (e) { 124 | echo "Few of the builds are not found to trigger. " + e 125 | } 126 | } 127 | 128 | } 129 | } 130 | 131 | stage('result') { 132 | steps { 133 | script { 134 | try { 135 | sh """ 136 | cd ${WORKSPACE} 137 | cat sucessresult.html 138 | cat failresult.html 139 | cd ${WORKSPACE}/WUM_LOGS/ 140 | """ 141 | 142 | if (fileExists("${WORKSPACE}/sucessresult.html")) { 143 | def emailBodySuccess = readFile "${WORKSPACE}/sucessresult.html" 144 | def emailBodyFail = readFile "${WORKSPACE}/failresult.html" 145 | String productList = readFile "${PRODUCT_LIST}" 146 | productList = convertToHtml(productList); 147 | def updateNo = readFile "${WORKSPACE}/WUM_LOGS/product-id-list.txt" 148 | 149 | send("[TestGrid][WUM] Scenario Test Results for WUM Updates! #(${env.BUILD_NUMBER})", """ 150 |
151 |
152 | 153 |
154 | 155 | 159 | 160 | 163 |
156 |

Scenario test results for WUM updates 157 |

158 |
161 | 162 |
164 |
165 |

166 | 167 | Testgrid job status 168 | 169 |

170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 |
Success jobsFailed/Unstable jobs
${emailBodySuccess}${emailBodyFail}
184 |
185 |

186 | 187 | Product information 188 | 189 |

190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 |
Product versionUpdate no.
${productList}${updateNo}
204 |
205 |

206 | 207 | Build Info: 208 | ${SCENARIO_BUILD_URL} 209 | 210 |

211 |
212 | Tested by WSO2 TestGrid. 213 |
214 |
215 | """) 216 | 217 | } else { 218 | println "No WUM Update found..!" 219 | send("Testgrid Test Results Summary for WUM Updates!", "No WUM Update found..!") 220 | } 221 | //Delete the WUM_LOGS 222 | dir("${WORKSPACE}/WUM_LOGS") { 223 | deleteDir() 224 | } 225 | 226 | } catch (e) { 227 | echo "Error while sending mail: " + e.getMessage() 228 | currentBuild.result = "FAILED" 229 | } 230 | } 231 | 232 | } 233 | } 234 | } 235 | 236 | } 237 | 238 | } 239 | } 240 | 241 | def send(subject, content) { 242 | emailext(to: "${EMAIL_TO_LIST}", 243 | subject: subject, 244 | body: content, mimeType: 'text/html') 245 | } 246 | 247 | static def convertToHtml(String productList) { 248 | StringBuilder sb = new StringBuilder("
"); 249 | for (String p : productList.split("\n")) { 250 | sb.append(p).append("
") 251 | } 252 | sb.append("
") 253 | return sb.toString() 254 | } 255 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /ise2e.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 WSO2 LLC. (https://www.wso2.com) All Rights Reserved. 3 | * 4 | * WSO2 LLC. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | import groovy.io.FileType 20 | import hudson.model.* 21 | 22 | def deploymentDirectories = [] 23 | def updateType = "" 24 | 25 | pipeline { 26 | agent {label 'pipeline-agent'} 27 | stages { 28 | stage('Clone CFN repo') { 29 | steps { 30 | script { 31 | cfn_repo_url="https://github.com/wso2/testgrid.git" 32 | cfn_repo_branch="master" 33 | if (pre_release.toBoolean()){ 34 | updateType="pre-release" 35 | } 36 | else{ 37 | updateType="u2" 38 | } 39 | dir("testgrid") { 40 | git branch: "${cfn_repo_branch}", 41 | credentialsId: "WSO2_GITHUB_TOKEN", 42 | url: "${cfn_repo_url}" 43 | } 44 | } 45 | } 46 | } 47 | stage('Constructing parameter files'){ 48 | steps { 49 | script { 50 | withCredentials([string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'accessKey'), 51 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'secretAccessKey'), 52 | string(credentialsId: 'WUM_USERNAME', variable: 'wumUserName'), 53 | string(credentialsId: 'WUM_PASSWORD', variable: 'wumPassword'), 54 | string(credentialsId: 'DEPLOYMENT_DB_PASSWORD', variable: 'dbPassword'), 55 | string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 's3accessKey'), 56 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 's3secretKey'), 57 | string(credentialsId: 'TESTGRID_EMAIL_PASSWORD', variable: 'testgridEmailPassword')]) 58 | { 59 | sh ''' 60 | echo "Writting AWS-Access Key ID to parameter file" 61 | ./scripts/write-parameter-file.sh "AWSAccessKeyId" ${accessKey} "${WORKSPACE}/parameters/parameters.json" 62 | echo "Writting AWS-Secret Access Key to parameter file" 63 | ./scripts/write-parameter-file.sh "AWSAccessKeySecret" ${secretAccessKey} "${WORKSPACE}/parameters/parameters.json" 64 | echo "Writting DB password to parameter file" 65 | ./scripts/write-parameter-file.sh "DBPassword" ${dbPassword} "${WORKSPACE}/parameters/parameters.json" 66 | echo "Writting S3 access key id to parameter file" 67 | ./scripts/write-parameter-file.sh "S3AccessKeyID" ${s3accessKey} "${WORKSPACE}/parameters/parameters.json" 68 | echo "Writting S3 secret access key to parameter file" 69 | ./scripts/write-parameter-file.sh "S3SecretAccessKey" ${s3secretKey} "${WORKSPACE}/parameters/parameters.json" 70 | echo "Writing testgrid email key to parameter file" 71 | ./scripts/write-parameter-file.sh "TESTGRID_EMAIL_PASSWORD" ${testgridEmailPassword} "${WORKSPACE}/parameters/parameters.json" 72 | ''' 73 | } 74 | withCredentials([usernamePassword(credentialsId: 'WSO2_GITHUB_TOKEN', usernameVariable: 'githubUserName', passwordVariable: 'githubPassword')]) 75 | { 76 | sh ''' 77 | echo "Writting Github Username to parameter file" 78 | ./scripts/write-parameter-file.sh "GithubUserName" ${githubUserName} "${WORKSPACE}/parameters/parameters.json" 79 | echo "Writting Github Password to parameter file" 80 | ./scripts/write-parameter-file.sh "GithubPassword" ${githubPassword} "${WORKSPACE}/parameters/parameters.json" 81 | ''' 82 | } 83 | sh ''' 84 | echo --- Adding common parameters to parameter file! --- 85 | echo "Writting product name to parameter file" 86 | ./scripts/write-parameter-file.sh "Product" ${product} "${WORKSPACE}/parameters/parameters.json" 87 | echo "Writting product version to parameter file" 88 | ./scripts/write-parameter-file.sh "ProductVersion" ${product_version} "${WORKSPACE}/parameters/parameters.json" 89 | echo "Writting product deployment region to parameter file" 90 | ./scripts/write-parameter-file.sh "Region" ${product_deployment_region} "${WORKSPACE}/parameters/parameters.json" 91 | echo "Writting product instance Type to parameter file" 92 | ./scripts/write-parameter-file.sh "WSO2InstanceType" ${product_instance_type} "${WORKSPACE}/parameters/parameters.json" 93 | echo "Writting product deployment cfn loction to parameter file" 94 | ./scripts/write-parameter-file.sh "CloudformationLocation" ${cloudformation_location} "${WORKSPACE}/parameters/parameters.json" 95 | echo "Writting product deployment ALB Certificate ARN to parameter file" 96 | ./scripts/write-parameter-file.sh "ALBCertificateARN" ${alb_cert_arn} "${WORKSPACE}/parameters/parameters.json" 97 | echo "Writting product deployment Product Repository to parameter file" 98 | ./scripts/write-parameter-file.sh "ProductRepository" ${product_repository} "${WORKSPACE}/parameters/parameters.json" 99 | echo "Writting product deployment Product Test Branch to parameter file" 100 | ./scripts/write-parameter-file.sh "ProductTestBranch" ${product_test_branch} "${WORKSPACE}/parameters/parameters.json" 101 | echo "Writting product deployment Product Test script location to parameter file" 102 | ./scripts/write-parameter-file.sh "ProductTestScriptLocation" ${product_test_script} "${WORKSPACE}/parameters/parameters.json" 103 | echo "Writting product update type to parameter file" 104 | ./scripts/write-parameter-file.sh "UpdateType" '''+updateType+''' "${WORKSPACE}/parameters/parameters.json" 105 | echo "Writting test type to parameter file" 106 | ./scripts/write-parameter-file.sh "TestType" "intg" "${WORKSPACE}/parameters/parameters.json" 107 | echo "Writting product Surefire Report Directory" 108 | ./scripts/write-parameter-file.sh "SurefireReportDir" ${surefire_report_dir} "${WORKSPACE}/parameters/parameters.json" 109 | echo "Writting product download location" 110 | ./scripts/write-parameter-file.sh "ProductPackLocation" ${product_pack_location} "${WORKSPACE}/parameters/parameters.json" 111 | echo "Writing to parameter file completed!" 112 | echo --- Preparing parameter files for deployments! --- 113 | ./scripts/deployment-builder.sh ${product} ${product_version} '''+updateType+''' 114 | ''' 115 | } 116 | } 117 | } 118 | 119 | stage('Deploying Testing and Logs Uploading') { 120 | steps { 121 | script { 122 | println "Creating deployments for the following combinations!" 123 | def deployment_path = "${WORKSPACE}/deployment" 124 | def command = ''' 125 | ls -l ${WORKSPACE}/deployment | grep -E "^d" | awk '{print $9}' 126 | ''' 127 | def procDirList = sh(returnStdout: true, script: command).trim().split("\\r?\\n") 128 | for (procDir in procDirList){ 129 | deploymentDirectories << procDir 130 | } 131 | def build_jobs = [:] 132 | for (deploymentDirectory in deploymentDirectories){ 133 | println deploymentDirectory 134 | build_jobs["${deploymentDirectory}"] = create_build_jobs(deploymentDirectory) 135 | } 136 | 137 | parallel build_jobs 138 | } 139 | } 140 | } 141 | } 142 | post { 143 | always { 144 | sh ''' 145 | echo "Job is completed... Deleting the workspace directories!" 146 | ''' 147 | script { 148 | sendEmail(deploymentDirectories, updateType) 149 | } 150 | cleanWs deleteDirs: true, notFailBuild: true 151 | } 152 | } 153 | } 154 | 155 | def create_build_jobs(deploymentDirectory){ 156 | return{ 157 | stage("${deploymentDirectory}"){ 158 | stage("Deploy ${deploymentDirectory}") { 159 | println "Deploying Stack:- ${deploymentDirectory}..." 160 | sh''' 161 | ./scripts/deployment-handler.sh '''+deploymentDirectory+''' ${WORKSPACE}/${cloudformation_location} 162 | ''' 163 | stage("Testing ${deploymentDirectory}") { 164 | println "Deployment Integration testing..." 165 | sh''' 166 | ./scripts/intg-test-deployment.sh '''+deploymentDirectory+''' ${product_repository} ${product_test_branch} ${product_test_script} 167 | ''' 168 | } 169 | } 170 | } 171 | } 172 | } 173 | 174 | def sendEmail(deploymentDirectories, updateType) { 175 | def deployments = "" 176 | for (deploymentDirectory in deploymentDirectories){ 177 | deployments = deployments + deploymentDirectory + "
" 178 | } 179 | 180 | if (currentBuild.currentResult.equals("SUCCESS")){ 181 | headerColour = "#05B349" 182 | }else{ 183 | headerColour = "#ff0000" 184 | } 185 | content=""" 186 |
187 |
188 |
189 | 190 | 193 | 196 |
191 |

E2E test results

192 |
194 | 195 |
197 |
198 |

199 | 200 | Testgrid job status 201 | 202 |

203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 |
Test SpecificationTest Values
Product${product.toUpperCase()}
Version${product_version}
Used Staging as Update${use_staging}
Used IAM pre-release${pre_release}
Operating Systems${os_list}
Databases${database_list}
JDKs${jdk_list}
Product Test Repository${product_repository}
Product Test Repository Branch${product_test_branch}
Product Depolyment Combinations${deployments}
253 |
254 |
255 |

256 | 257 | Build Info: 258 | ${BUILD_URL} 259 | 260 |

261 |
262 |
263 |
264 | Tested by WSO2 Jenkins TestGrid Pipeline. 265 |
266 | """ 267 | subject="[TestGrid][${updateType.toUpperCase()}][${product.toUpperCase()}:${product_version}][E2E]-Build ${currentBuild.currentResult}-#${env.BUILD_NUMBER}" 268 | senderEmailGroup="iam-builder@wso2.com" 269 | emailext(to: "${senderEmailGroup},builder@wso2.org", 270 | subject: subject, 271 | body: content, mimeType: 'text/html') 272 | } 273 | -------------------------------------------------------------------------------- /isintegration.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 WSO2 LLC. (https://www.wso2.com) All Rights Reserved. 3 | * 4 | * WSO2 LLC. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | import groovy.io.FileType 20 | import hudson.model.* 21 | 22 | def deploymentDirectories = [] 23 | def updateType = "" 24 | 25 | pipeline { 26 | agent {label 'pipeline-agent'} 27 | stages { 28 | stage('Clone CFN repo') { 29 | steps { 30 | script { 31 | cfn_repo_url="https://github.com/wso2/testgrid.git" 32 | cfn_repo_branch="master" 33 | if (pre_release.toBoolean()){ 34 | updateType="pre-release" 35 | } 36 | else{ 37 | updateType="u2" 38 | } 39 | dir("testgrid") { 40 | git branch: "${cfn_repo_branch}", 41 | credentialsId: "WSO2_GITHUB_TOKEN", 42 | url: "${cfn_repo_url}" 43 | } 44 | } 45 | } 46 | } 47 | stage('Constructing parameter files'){ 48 | steps { 49 | script { 50 | withCredentials([string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'accessKey'), 51 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'secretAccessKey'), 52 | string(credentialsId: 'WUM_USERNAME', variable: 'wumUserName'), 53 | string(credentialsId: 'WUM_PASSWORD', variable: 'wumPassword'), 54 | string(credentialsId: 'DEPLOYMENT_DB_PASSWORD', variable: 'dbPassword'), 55 | string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 's3accessKey'), 56 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 's3secretKey'), 57 | string(credentialsId: 'TESTGRID_EMAIL_PASSWORD', variable: 'testgridEmailPassword')]) 58 | { 59 | sh ''' 60 | echo "Writting AWS-Access Key ID to parameter file" 61 | ./scripts/write-parameter-file.sh "AWSAccessKeyId" ${accessKey} "${WORKSPACE}/parameters/parameters.json" 62 | echo "Writting AWS-Secret Access Key to parameter file" 63 | ./scripts/write-parameter-file.sh "AWSAccessKeySecret" ${secretAccessKey} "${WORKSPACE}/parameters/parameters.json" 64 | echo "Writting WUM Password to parameter file" 65 | ./scripts/write-parameter-file.sh "WUMPassword" ${wumPassword} "${WORKSPACE}/parameters/parameters.json" 66 | echo "Writting WUM Username to parameter file" 67 | ./scripts/write-parameter-file.sh "WUMUsername" ${wumUserName} "${WORKSPACE}/parameters/parameters.json" 68 | echo "Writting DB password to parameter file" 69 | ./scripts/write-parameter-file.sh "DBPassword" ${dbPassword} "${WORKSPACE}/parameters/parameters.json" 70 | echo "Writting S3 access key id to parameter file" 71 | ./scripts/write-parameter-file.sh "S3AccessKeyID" ${s3accessKey} "${WORKSPACE}/parameters/parameters.json" 72 | echo "Writting S3 secret access key to parameter file" 73 | ./scripts/write-parameter-file.sh "S3SecretAccessKey" ${s3secretKey} "${WORKSPACE}/parameters/parameters.json" 74 | echo "Writing testgrid email key to parameter file" 75 | ./scripts/write-parameter-file.sh "TESTGRID_EMAIL_PASSWORD" ${testgridEmailPassword} "${WORKSPACE}/parameters/parameters.json" 76 | ''' 77 | } 78 | withCredentials([usernamePassword(credentialsId: 'WSO2_GITHUB_TOKEN', usernameVariable: 'githubUserName', passwordVariable: 'githubPassword')]) 79 | { 80 | sh ''' 81 | echo "Writting Github Username to parameter file" 82 | ./scripts/write-parameter-file.sh "GithubUserName" ${githubUserName} "${WORKSPACE}/parameters/parameters.json" 83 | echo "Writting Github Password to parameter file" 84 | ./scripts/write-parameter-file.sh "GithubPassword" ${githubPassword} "${WORKSPACE}/parameters/parameters.json" 85 | ''' 86 | } 87 | sh ''' 88 | echo --- Adding common parameters to parameter file! --- 89 | echo "Writting product name to parameter file" 90 | ./scripts/write-parameter-file.sh "Product" ${product} "${WORKSPACE}/parameters/parameters.json" 91 | echo "Writting product version to parameter file" 92 | ./scripts/write-parameter-file.sh "ProductVersion" ${product_version} "${WORKSPACE}/parameters/parameters.json" 93 | echo "Writting product deployment region to parameter file" 94 | ./scripts/write-parameter-file.sh "Region" ${product_deployment_region} "${WORKSPACE}/parameters/parameters.json" 95 | echo "Writting product instance Type to parameter file" 96 | ./scripts/write-parameter-file.sh "WSO2InstanceType" ${product_instance_type} "${WORKSPACE}/parameters/parameters.json" 97 | echo "Writting product deployment cfn loction to parameter file" 98 | ./scripts/write-parameter-file.sh "CloudformationLocation" ${cloudformation_location} "${WORKSPACE}/parameters/parameters.json" 99 | echo "Writting product deployment ALB Certificate ARN to parameter file" 100 | ./scripts/write-parameter-file.sh "ALBCertificateARN" ${alb_cert_arn} "${WORKSPACE}/parameters/parameters.json" 101 | echo "Writting product deployment Product Repository to parameter file" 102 | ./scripts/write-parameter-file.sh "ProductRepository" ${product_repository} "${WORKSPACE}/parameters/parameters.json" 103 | echo "Writting product deployment Product Test Branch to parameter file" 104 | ./scripts/write-parameter-file.sh "ProductTestBranch" ${product_test_branch} "${WORKSPACE}/parameters/parameters.json" 105 | echo "Writting product deployment Product Test script location to parameter file" 106 | ./scripts/write-parameter-file.sh "ProductTestScriptLocation" ${product_test_script} "${WORKSPACE}/parameters/parameters.json" 107 | echo "Writting product update type to parameter file" 108 | ./scripts/write-parameter-file.sh "UpdateType" '''+updateType+''' "${WORKSPACE}/parameters/parameters.json" 109 | echo "Writting test type to parameter file" 110 | ./scripts/write-parameter-file.sh "TestType" "intg" "${WORKSPACE}/parameters/parameters.json" 111 | echo "Writting product Surefire Report Directory" 112 | ./scripts/write-parameter-file.sh "SurefireReportDir" ${surefire_report_dir} "${WORKSPACE}/parameters/parameters.json" 113 | echo "Writting product download location" 114 | ./scripts/write-parameter-file.sh "ProductPackLocation" ${product_pack_location} "${WORKSPACE}/parameters/parameters.json" 115 | echo "Writing to parameter file completed!" 116 | echo --- Preparing parameter files for deployments! --- 117 | ./scripts/deployment-builder.sh ${product} ${product_version} '''+updateType+''' 118 | ''' 119 | } 120 | } 121 | } 122 | stage('Deploying Testing and Logs Uploading') { 123 | steps { 124 | script { 125 | println "Creating deployments for the following combinations!" 126 | def deployment_path = "${WORKSPACE}/deployment" 127 | def command = ''' 128 | ls -l ${WORKSPACE}/deployment | grep -E "^d" | awk '{print $9}' 129 | ''' 130 | def procDirList = sh(returnStdout: true, script: command).trim().split("\\r?\\n") 131 | for (procDir in procDirList){ 132 | deploymentDirectories << procDir 133 | } 134 | def build_jobs = [:] 135 | for (deploymentDirectory in deploymentDirectories){ 136 | println deploymentDirectory 137 | build_jobs["${deploymentDirectory}"] = create_build_jobs(deploymentDirectory) 138 | } 139 | 140 | parallel build_jobs 141 | } 142 | } 143 | } 144 | } 145 | post { 146 | always { 147 | sh ''' 148 | echo "Job is completed... Deleting the workspace directories!" 149 | ''' 150 | script { 151 | sendEmail(deploymentDirectories, updateType) 152 | } 153 | cleanWs deleteDirs: true, notFailBuild: true 154 | } 155 | } 156 | } 157 | 158 | def create_build_jobs(deploymentDirectory){ 159 | return{ 160 | stage("${deploymentDirectory}"){ 161 | stage("Deploy ${deploymentDirectory}") { 162 | println "Deploying Stack:- ${deploymentDirectory}..." 163 | sh''' 164 | ./scripts/deployment-handler.sh '''+deploymentDirectory+''' ${WORKSPACE}/${cloudformation_location} 165 | ''' 166 | stage("Testing ${deploymentDirectory}") { 167 | println "Deployment Integration testing..." 168 | sh''' 169 | ./scripts/intg-test-deployment.sh '''+deploymentDirectory+''' ${product_repository} ${product_test_branch} ${product_test_script} 170 | ''' 171 | } 172 | } 173 | } 174 | } 175 | } 176 | 177 | def sendEmail(deploymentDirectories, updateType) { 178 | def deployments = "" 179 | for (deploymentDirectory in deploymentDirectories){ 180 | deployments = deployments + deploymentDirectory + "
" 181 | } 182 | 183 | if (currentBuild.currentResult.equals("SUCCESS")){ 184 | headerColour = "#05B349" 185 | }else{ 186 | headerColour = "#ff0000" 187 | } 188 | content=""" 189 |
190 |
191 |
192 | 193 | 196 | 199 |
194 |

Integration test results

195 |
197 | 198 |
200 |
201 |

202 | 203 | Testgrid job status 204 | 205 |

206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
Test SpecificationTest Values
Product${product.toUpperCase()}
Version${product_version}
Used Staging as Update${use_staging}
Used IAM pre-release${pre_release}
Operating Systems${os_list}
Databases${database_list}
JDKs${jdk_list}
Product Test Repository${product_repository}
Product Test Repository Branch${product_test_branch}
Product Depolyment Combinations${deployments}
256 |
257 |
258 |

259 | 260 | Build Info: 261 | ${BUILD_URL} 262 | 263 |

264 |
265 |
266 |
267 | Tested by WSO2 Jenkins TestGrid Pipeline. 268 |
269 | """ 270 | subject="[TestGrid][${updateType.toUpperCase()}][${product.toUpperCase()}:${product_version}][INTG]-Build ${currentBuild.currentResult}-#${env.BUILD_NUMBER}" 271 | senderEmailGroup="iam-builder@wso2.com" 272 | emailext(to: "${senderEmailGroup},builder@wso2.org", 273 | subject: subject, 274 | body: content, mimeType: 'text/html') 275 | } 276 | -------------------------------------------------------------------------------- /integration.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | import groovy.io.FileType 20 | import hudson.model.* 21 | 22 | def deploymentDirectories = [] 23 | def updateType = "" 24 | 25 | pipeline { 26 | agent {label 'pipeline-agent'} 27 | stages { 28 | stage('Clone CFN repo') { 29 | steps { 30 | script { 31 | cfn_repo_url="https://github.com/wso2/testgrid.git" 32 | cfn_repo_branch="master" 33 | if (apim_pre_release.toBoolean()){ 34 | cfn_repo_branch="apim-pre-release" 35 | } 36 | if (use_wum.toBoolean()){ 37 | updateType="wum" 38 | }else{ 39 | updateType="u2" 40 | } 41 | dir("testgrid") { 42 | git branch: "${cfn_repo_branch}", 43 | credentialsId: "WSO2_GITHUB_TOKEN", 44 | url: "${cfn_repo_url}" 45 | } 46 | } 47 | } 48 | } 49 | stage('Constructing parameter files'){ 50 | steps { 51 | script { 52 | withCredentials([string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'accessKey'), 53 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'secretAccessKey'), 54 | string(credentialsId: 'WUM_USERNAME', variable: 'wumUserName'), 55 | string(credentialsId: 'WUM_PASSWORD', variable: 'wumPassword'), 56 | string(credentialsId: 'DEPLOYMENT_DB_PASSWORD', variable: 'dbPassword'), 57 | string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 's3accessKey'), 58 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 's3secretKey'), 59 | string(credentialsId: 'TESTGRID_EMAIL_PASSWORD', variable: 'testgridEmailPassword')]) 60 | { 61 | sh ''' 62 | echo "Writting AWS-Access Key ID to parameter file" 63 | ./scripts/write-parameter-file.sh "AWSAccessKeyId" ${accessKey} "${WORKSPACE}/parameters/parameters.json" 64 | echo "Writting AWS-Secret Access Key to parameter file" 65 | ./scripts/write-parameter-file.sh "AWSAccessKeySecret" ${secretAccessKey} "${WORKSPACE}/parameters/parameters.json" 66 | echo "Writting WUM Password to parameter file" 67 | ./scripts/write-parameter-file.sh "WUMPassword" ${wumPassword} "${WORKSPACE}/parameters/parameters.json" 68 | echo "Writting WUM Username to parameter file" 69 | ./scripts/write-parameter-file.sh "WUMUsername" ${wumUserName} "${WORKSPACE}/parameters/parameters.json" 70 | echo "Writting DB password to parameter file" 71 | ./scripts/write-parameter-file.sh "DBPassword" ${dbPassword} "${WORKSPACE}/parameters/parameters.json" 72 | echo "Writting S3 access key id to parameter file" 73 | ./scripts/write-parameter-file.sh "S3AccessKeyID" ${s3accessKey} "${WORKSPACE}/parameters/parameters.json" 74 | echo "Writting S3 secret access key to parameter file" 75 | ./scripts/write-parameter-file.sh "S3SecretAccessKey" ${s3secretKey} "${WORKSPACE}/parameters/parameters.json" 76 | echo "Writing testgrid email key to parameter file" 77 | ./scripts/write-parameter-file.sh "TESTGRID_EMAIL_PASSWORD" ${testgridEmailPassword} "${WORKSPACE}/parameters/parameters.json" 78 | ''' 79 | } 80 | withCredentials([usernamePassword(credentialsId: 'WSO2_GITHUB_TOKEN', usernameVariable: 'githubUserName', passwordVariable: 'githubPassword')]) 81 | { 82 | sh ''' 83 | echo "Writting Github Username to parameter file" 84 | ./scripts/write-parameter-file.sh "GithubUserName" ${githubUserName} "${WORKSPACE}/parameters/parameters.json" 85 | echo "Writting Github Password to parameter file" 86 | ./scripts/write-parameter-file.sh "GithubPassword" ${githubPassword} "${WORKSPACE}/parameters/parameters.json" 87 | ''' 88 | } 89 | sh ''' 90 | echo --- Adding common parameters to parameter file! --- 91 | echo "Writting product name to parameter file" 92 | ./scripts/write-parameter-file.sh "Product" ${product} "${WORKSPACE}/parameters/parameters.json" 93 | echo "Writting product version to parameter file" 94 | ./scripts/write-parameter-file.sh "ProductVersion" ${product_version} "${WORKSPACE}/parameters/parameters.json" 95 | echo "Writting product deployment region to parameter file" 96 | ./scripts/write-parameter-file.sh "Region" ${product_deployment_region} "${WORKSPACE}/parameters/parameters.json" 97 | echo "Writting product instance Type to parameter file" 98 | ./scripts/write-parameter-file.sh "WSO2InstanceType" ${product_instance_type} "${WORKSPACE}/parameters/parameters.json" 99 | echo "Writting product deployment cfn loction to parameter file" 100 | ./scripts/write-parameter-file.sh "CloudformationLocation" ${cloudformation_location} "${WORKSPACE}/parameters/parameters.json" 101 | echo "Writting product deployment ALB Certificate ARN to parameter file" 102 | ./scripts/write-parameter-file.sh "ALBCertificateARN" ${alb_cert_arn} "${WORKSPACE}/parameters/parameters.json" 103 | echo "Writting product deployment Product Repository to parameter file" 104 | ./scripts/write-parameter-file.sh "ProductRepository" ${product_repository} "${WORKSPACE}/parameters/parameters.json" 105 | echo "Writting product deployment Product Test Branch to parameter file" 106 | ./scripts/write-parameter-file.sh "ProductTestBranch" ${product_test_branch} "${WORKSPACE}/parameters/parameters.json" 107 | echo "Writting product deployment Product Test script location to parameter file" 108 | ./scripts/write-parameter-file.sh "ProductTestScriptLocation" ${product_test_script} "${WORKSPACE}/parameters/parameters.json" 109 | echo "Writting product update type to parameter file" 110 | ./scripts/write-parameter-file.sh "UpdateType" '''+updateType+''' "${WORKSPACE}/parameters/parameters.json" 111 | echo "Writting test type to parameter file" 112 | ./scripts/write-parameter-file.sh "TestType" "intg" "${WORKSPACE}/parameters/parameters.json" 113 | echo "Writting product Surefire Report Directory" 114 | ./scripts/write-parameter-file.sh "SurefireReportDir" ${surefire_report_dir} "${WORKSPACE}/parameters/parameters.json" 115 | echo "Writting product download location" 116 | ./scripts/write-parameter-file.sh "ProductPackLocation" ${product_pack_location} "${WORKSPACE}/parameters/parameters.json" 117 | echo "Writing to parameter file completed!" 118 | echo --- Preparing parameter files for deployments! --- 119 | ./scripts/deployment-builder.sh ${product} ${product_version} '''+updateType+''' 120 | ''' 121 | } 122 | } 123 | } 124 | stage('Deploying Testing and Logs Uploading') { 125 | steps { 126 | script { 127 | println "Creating deployments for the following combinations!" 128 | def deployment_path = "${WORKSPACE}/deployment" 129 | def command = ''' 130 | ls -l ${WORKSPACE}/deployment | grep -E "^d" | awk '{print $9}' 131 | ''' 132 | def procDirList = sh(returnStdout: true, script: command).trim().split("\\r?\\n") 133 | for (procDir in procDirList){ 134 | deploymentDirectories << procDir 135 | } 136 | def build_jobs = [:] 137 | for (deploymentDirectory in deploymentDirectories){ 138 | println deploymentDirectory 139 | build_jobs["${deploymentDirectory}"] = create_build_jobs(deploymentDirectory) 140 | } 141 | 142 | parallel build_jobs 143 | } 144 | } 145 | } 146 | } 147 | post { 148 | always { 149 | sh ''' 150 | echo "Job is completed... Deleting the workspace directories!" 151 | ''' 152 | script { 153 | sendEmail(deploymentDirectories, updateType) 154 | } 155 | cleanWs deleteDirs: true, notFailBuild: true 156 | } 157 | } 158 | } 159 | 160 | def create_build_jobs(deploymentDirectory){ 161 | return{ 162 | stage("${deploymentDirectory}"){ 163 | stage("Deploy ${deploymentDirectory}") { 164 | println "Deploying Stack:- ${deploymentDirectory}..." 165 | sh''' 166 | ./scripts/deployment-handler.sh '''+deploymentDirectory+''' ${WORKSPACE}/${cloudformation_location} 167 | ''' 168 | stage("Testing ${deploymentDirectory}") { 169 | println "Deployment Integration testing..." 170 | sh''' 171 | ./scripts/intg-test-deployment.sh '''+deploymentDirectory+''' ${product_repository} ${product_test_branch} ${product_test_script} 172 | ''' 173 | } 174 | } 175 | } 176 | } 177 | } 178 | 179 | def sendEmail(deploymentDirectories, updateType) { 180 | def deployments = "" 181 | for (deploymentDirectory in deploymentDirectories){ 182 | deployments = deployments + deploymentDirectory + "
" 183 | } 184 | 185 | if (currentBuild.currentResult.equals("SUCCESS")){ 186 | headerColour = "#05B349" 187 | }else{ 188 | headerColour = "#ff0000" 189 | } 190 | content=""" 191 |
192 |
193 |
194 | 195 | 198 | 201 |
196 |

Integration test results

197 |
199 | 200 |
202 |
203 |

204 | 205 | Testgrid job status 206 | 207 |

208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 |
Test SpecificationTest Values
Product${product.toUpperCase()}
Version${product_version}
Used WUM as Update${use_wum}
Used Staging as Update${use_staging}
Used APIM pre-release${apim_pre_release}
Operating Systems${os_list}
Databases${database_list}
JDKs${jdk_list}
Product Test Repository${product_repository}
Product Test Repository Branch${product_test_branch}
Product Depolyment Combinations${deployments}
262 |
263 |
264 |

265 | 266 | Build Info: 267 | ${BUILD_URL} 268 | 269 |

270 |
271 |
272 |
273 | Tested by WSO2 Jenkins TestGrid Pipeline. 274 |
275 | """ 276 | subject="[TestGrid][${updateType.toUpperCase()}][${product.toUpperCase()}:${product_version}][INTG]-Build ${currentBuild.currentResult}-#${env.BUILD_NUMBER}" 277 | senderEmailGroup="" 278 | if(product.equals("wso2am") || product.equals("ei") || product.equals("esb") || product.equals("mi")){ 279 | senderEmailGroup = "integration-builder@wso2.com" 280 | }else if(product.equals("is")) { 281 | senderEmailGroup = "iam-builder@wso2.com" 282 | }else if(product.equals("ob")) { 283 | senderEmailGroup = "bfsi-group@wso2.com" 284 | } 285 | emailext(to: "${senderEmailGroup},builder@wso2.org", 286 | subject: subject, 287 | body: content, mimeType: 'text/html') 288 | } 289 | -------------------------------------------------------------------------------- /main.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | import groovy.io.FileType 20 | import hudson.model.* 21 | 22 | def deploymentDirectories = [] 23 | def updateType = "" 24 | def s3BucketName = "testgrid-pipeline-logs" 25 | def s3BuildLogPath = "" 26 | def s3PathConstructor = "" 27 | 28 | pipeline { 29 | agent {label 'pipeline-agent'} 30 | stages { 31 | stage('Clone CFN repo') { 32 | steps { 33 | script { 34 | aws_repo_branch="" 35 | if (use_staging.toBoolean()) { 36 | if (use_wum.toBoolean()){ 37 | aws_repo_branch="${product_version}-staging-new" 38 | updateType="wum" 39 | s3PathConstructor="staging/wum" 40 | }else{ 41 | aws_repo_branch="${product_version}-u2-staging-new" 42 | updateType="u2" 43 | s3PathConstructor="staging/u2" 44 | } 45 | } else { 46 | if (use_wum.toBoolean()){ 47 | aws_repo_branch="${product_version}-new" 48 | updateType="wum" 49 | s3PathConstructor="wum" 50 | }else{ 51 | aws_repo_branch="${product_version}-u2-new" 52 | updateType="u2" 53 | s3PathConstructor="u2" 54 | } 55 | } 56 | dir("aws-"+product) { 57 | git branch: "${aws_repo_branch}", 58 | credentialsId: "WSO2_GITHUB_TOKEN", 59 | url: "${cfn_repo_url}" 60 | } 61 | } 62 | } 63 | } 64 | stage('Constructing parameter files'){ 65 | steps { 66 | script { 67 | withCredentials([string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'accessKey'), 68 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'secretAccessKey'), 69 | string(credentialsId: 'WUM_USERNAME', variable: 'wumUserName'), 70 | string(credentialsId: 'WUM_PASSWORD', variable: 'wumPassword'), 71 | string(credentialsId: 'DEPLOYMENT_DB_PASSWORD', variable: 'dbPassword'), 72 | string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 's3accessKey'), 73 | string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 's3secretKey'), 74 | string(credentialsId: 'TESTGRID_EMAIL_PASSWORD', variable: 'testgridEmailPassword')]) 75 | { 76 | sh ''' 77 | echo "Writting AWS-Access Key ID to parameter file" 78 | ./scripts/write-parameter-file.sh "AWSAccessKeyId" ${accessKey} "${WORKSPACE}/parameters/parameters.json" 79 | echo "Writting AWS-Secret Access Key to parameter file" 80 | ./scripts/write-parameter-file.sh "AWSAccessKeySecret" ${secretAccessKey} "${WORKSPACE}/parameters/parameters.json" 81 | echo "Writting WUM Password to parameter file" 82 | ./scripts/write-parameter-file.sh "WUMPassword" ${wumPassword} "${WORKSPACE}/parameters/parameters.json" 83 | echo "Writting WUM Username to parameter file" 84 | ./scripts/write-parameter-file.sh "WUMUsername" ${wumUserName} "${WORKSPACE}/parameters/parameters.json" 85 | echo "Writting DB password to parameter file" 86 | ./scripts/write-parameter-file.sh "DBPassword" ${dbPassword} "${WORKSPACE}/parameters/parameters.json" 87 | echo "Writting S3 access key id to parameter file" 88 | ./scripts/write-parameter-file.sh "S3AccessKeyID" ${s3accessKey} "${WORKSPACE}/parameters/parameters.json" 89 | echo "Writting S3 secret access key to parameter file" 90 | ./scripts/write-parameter-file.sh "S3SecretAccessKey" ${s3secretKey} "${WORKSPACE}/parameters/parameters.json" 91 | echo "Writing testgrid email key to parameter file" 92 | ./scripts/write-parameter-file.sh "TESTGRID_EMAIL_PASSWORD" ${testgridEmailPassword} "${WORKSPACE}/parameters/parameters.json" 93 | ''' 94 | } 95 | withCredentials([usernamePassword(credentialsId: 'WSO2_GITHUB_TOKEN', usernameVariable: 'githubUserName', passwordVariable: 'githubPassword')]) 96 | { 97 | sh ''' 98 | echo "Writting Github Username to parameter file" 99 | ./scripts/write-parameter-file.sh "GithubUserName" ${githubUserName} "${WORKSPACE}/parameters/parameters.json" 100 | echo "Writting Github Password to parameter file" 101 | ./scripts/write-parameter-file.sh "GithubPassword" ${githubPassword} "${WORKSPACE}/parameters/parameters.json" 102 | ''' 103 | } 104 | sh ''' 105 | echo --- Adding common parameters to parameter file! --- 106 | echo "Writting product name to parameter file" 107 | ./scripts/write-parameter-file.sh "Product" ${product} "${WORKSPACE}/parameters/parameters.json" 108 | echo "Writting product version to parameter file" 109 | ./scripts/write-parameter-file.sh "ProductVersion" ${product_version} "${WORKSPACE}/parameters/parameters.json" 110 | echo "Writting product deployment region to parameter file" 111 | ./scripts/write-parameter-file.sh "Region" ${product_deployment_region} "${WORKSPACE}/parameters/parameters.json" 112 | echo "Writing custom URL to parameter file" 113 | ./scripts/write-parameter-file.sh "CustomURL" ${custom_url} "${WORKSPACE}/parameters/parameters.json" 114 | ''' 115 | //Generate S3 Log output path 116 | s3BuildLogPath = "${s3BucketName}/artifacts/jobs/${s3PathConstructor}/${product}-${product_version}/build-${BUILD_NUMBER}" 117 | println "Your Logs will be uploaded to: s3://"+s3BuildLogPath 118 | sh''' 119 | echo "Writting S3 Log uploading endpoint to parameter file" 120 | ./scripts/write-parameter-file.sh "S3OutputBucketLocation" '''+s3BuildLogPath+''' "${WORKSPACE}/parameters/parameters.json" 121 | echo "Writing to parameter file completed!" 122 | echo --- Preparing parameter files for deployments! --- 123 | ./scripts/deployment-builder.sh ${product} ${product_version} '''+updateType+''' 124 | ''' 125 | } 126 | } 127 | } 128 | stage('Deploying Testing and Logs Uploading') { 129 | steps { 130 | script { 131 | println "Creating deployments for the following combinations!" 132 | def deployment_path = "${WORKSPACE}/deployment" 133 | def command = ''' 134 | ls -l ${WORKSPACE}/deployment | grep -E "^d" | awk '{print $9}' 135 | ''' 136 | def procDirList = sh(returnStdout: true, script: command).trim().split("\\r?\\n") 137 | for (procDir in procDirList){ 138 | deploymentDirectories << procDir 139 | } 140 | def build_jobs = [:] 141 | for (deploymentDirectory in deploymentDirectories){ 142 | println deploymentDirectory 143 | build_jobs["${deploymentDirectory}"] = create_build_jobs(deploymentDirectory) 144 | } 145 | 146 | parallel build_jobs 147 | } 148 | } 149 | } 150 | } 151 | post { 152 | always { 153 | sh ''' 154 | echo "Arranging the log files!" 155 | parameters_directory="${WORKSPACE}/parameters/parameters.json" 156 | 157 | localLogDir="build-${BUILD_NUMBER}" 158 | mkdir -p ${localLogDir} 159 | aws s3 cp s3://'''+s3BuildLogPath+'''/ ${localLogDir} --recursive --quiet 160 | echo "Job is completed... Deleting the workspace directories!" 161 | ''' 162 | archiveArtifacts artifacts: "build-${env.BUILD_NUMBER}/**/*.*", fingerprint: true 163 | script { 164 | sendEmail(deploymentDirectories, updateType) 165 | } 166 | cleanWs deleteDirs: true, notFailBuild: true 167 | } 168 | } 169 | } 170 | 171 | def create_build_jobs(deploymentDirectory){ 172 | return{ 173 | stage("${deploymentDirectory}"){ 174 | stage("Deploy ${deploymentDirectory}") { 175 | println "Deploying Stack:- ${deploymentDirectory}..." 176 | String[] cloudformationLocation = [] 177 | switch(product) { 178 | case "apim": 179 | cloudformationLocation = ["${WORKSPACE}/aws-apim/apim/Minimum-HA/apim.yaml"] 180 | break; 181 | case "is": 182 | // The deployment is done in the indexed order 183 | cloudformationLocation = ["${WORKSPACE}/aws-is/is/Minimum-HA/identity.yaml", "${WORKSPACE}/aws-is/is-samples/test-is-samples.yml"] 184 | break; 185 | case "ei": 186 | cloudformationLocation = ["${WORKSPACE}/aws-ei/integrator/Minimum-HA/integrator-ha.yaml"] 187 | break; 188 | case "esb": 189 | cloudformationLocation = ["${WORKSPACE}/aws-esb/esb/Minimum-HA/esb-ha.yaml"] 190 | break; 191 | case "mi": 192 | cloudformationLocation = ["${WORKSPACE}/aws-mi/micro-integrator.yaml"] 193 | break; 194 | case "ob": 195 | cloudformationLocation = ["${WORKSPACE}/aws-ob/obam-with-obkm.yaml"] 196 | break; 197 | default: 198 | println("Product name is incorrect! Existing the execution"); 199 | currentBuild.result = 'ABORTED' 200 | } 201 | sh''' 202 | ./scripts/deployment-handler.sh '''+deploymentDirectory+''' '''+cloudformationLocation+''' 203 | ''' 204 | stage("Testing ${deploymentDirectory}") { 205 | println "Deployment testing..." 206 | sh''' 207 | ./scripts/test-deployment.sh '''+deploymentDirectory+''' ${product_repository} ${product_test_branch} ${product_test_script} 208 | ''' 209 | stage("Uploading results to ${deploymentDirectory}") { 210 | println "Upoading logs..." 211 | sh''' 212 | ./scripts/post-actions.sh '''+deploymentDirectory+''' 213 | ''' 214 | } 215 | } 216 | } 217 | } 218 | } 219 | } 220 | 221 | def sendEmail(deploymentDirectories, updateType) { 222 | def deployments = "" 223 | for (deploymentDirectory in deploymentDirectories){ 224 | deployments = deployments + deploymentDirectory + "
" 225 | } 226 | 227 | if (currentBuild.currentResult.equals("SUCCESS")){ 228 | headerColour = "#05B349" 229 | }else{ 230 | headerColour = "#ff0000" 231 | } 232 | content=""" 233 |
234 |
235 |
236 | 237 | 240 | 243 |
238 |

Scenario test results

239 |
241 | 242 |
244 |
245 |

246 | 247 | Testgrid job status 248 | 249 |

250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 |
Test SpecificationTest Values
Product${product.toUpperCase()}
Version${product_version}
Used WUM as Update${use_wum}
Used Staging as Update${use_staging}
Operating Systems${os_list}
Databases${database_list}
JDKs${jdk_list}
Product Test Repository${product_repository}
Product Test Repository Branch${product_test_branch}
Product Depolyment Combinations${deployments}
300 |
301 |
302 |

303 | 304 | Build Info: 305 | ${BUILD_URL} 306 | 307 |

308 |
309 |
310 |
311 | Tested by WSO2 Jenkins TestGrid Pipeline. 312 |
313 | """ 314 | subject="[TestGrid][${updateType.toUpperCase()}][${product.toUpperCase()}:${product_version}][SCE]-Build ${currentBuild.currentResult}-#${env.BUILD_NUMBER}" 315 | senderEmailGroup="" 316 | if(product.equals("apim") || product.equals("ei") || product.equals("esb") || product.equals("mi")){ 317 | senderEmailGroup = "integration-builder@wso2.com" 318 | }else if(product.equals("is")) { 319 | senderEmailGroup = "iam-builder@wso2.com" 320 | }else if(product.equals("ob")) { 321 | senderEmailGroup = "bfsi-group@wso2.com" 322 | } 323 | emailext(to: "${senderEmailGroup},builder@wso2.org", 324 | subject: subject, 325 | body: content, mimeType: 'text/html') 326 | } 327 | -------------------------------------------------------------------------------- /kubernetes/product-deployment/main.jenkins: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | 20 | pipeline { 21 | agent {label 'pipeline-kubernetes-agent'} 22 | environment { 23 | EKS_CLUSTER_REGION = 'us-east-1' 24 | EKS_CLUSTER_NAME = 'testgrid-eks-cluster' 25 | RDS_STACK_NAME = 'testgrid-rds-stack' 26 | DB_USERNAME = 'root' 27 | DB_PASSWORD = '613296496' 28 | } 29 | stages { 30 | stage('Clone repo') { 31 | steps { 32 | script { 33 | properties([ 34 | parameters([ 35 | separator(name: "PRODUCT_ENVIRONMENT", sectionHeader: "Product Details", 36 | separatorStyle: "border-width: 0", 37 | sectionHeaderStyle: """ 38 | background-color: #7ea6d3; 39 | text-align: center; 40 | padding: 4px; 41 | color: #343434; 42 | font-size: 22px; 43 | font-weight: normal; 44 | text-transform: uppercase; 45 | font-family: 'Orienta', sans-serif; 46 | letter-spacing: 1px; 47 | font-style: italic; 48 | margin-bottom: 25px; 49 | """), 50 | string( 51 | name: 'product_name', 52 | defaultValue: 'apim', 53 | description: 'Product name', 54 | trim: true 55 | ), 56 | string( 57 | name: 'product_version', 58 | defaultValue: '4.1.0', 59 | description: 'Product version', 60 | trim: true 61 | ), 62 | separator(name: "AWS_ENVIRONMENT", sectionHeader: "AWS cloudformation Details", 63 | separatorStyle: "border-width: 0", 64 | sectionHeaderStyle: """ 65 | background-color: #7ea6d3; 66 | text-align: center; 67 | padding: 4px; 68 | color: #343434; 69 | font-size: 22px; 70 | font-weight: normal; 71 | text-transform: uppercase; 72 | font-family: 'Orienta', sans-serif; 73 | letter-spacing: 1px; 74 | font-style: italic; 75 | margin-bottom: 25px; 76 | """), 77 | string( 78 | name: 'deployment_script_repo_url', 79 | defaultValue: 'https://github.com/wso2/apim-test-integration', 80 | description: 'Product deployment script repository.', 81 | trim: true 82 | ), 83 | string( 84 | name: 'deployment_script_repo_branch', 85 | defaultValue: '4.1.0-profile-automation', 86 | description: 'Branch name of the deployment script repository.', 87 | trim: true 88 | ), 89 | string( 90 | name: 'db_engine', 91 | defaultValue: 'mysql', 92 | description: 'Database engine', 93 | trim: true 94 | ), 95 | string( 96 | name: 'db_version', 97 | defaultValue: '8.0.28', 98 | description: 'Database engine version', 99 | trim: true 100 | ), 101 | string( 102 | name: 'db_instance_class', 103 | defaultValue: 'db.t3.small', 104 | description: 'Database engine instance class', 105 | trim: true 106 | ), 107 | separator(name: "KUBERNETES_ENVIRONMENT", sectionHeader: "Kubernetes Details", 108 | separatorStyle: "border-width: 0", 109 | sectionHeaderStyle: """ 110 | background-color: #7ea6d3; 111 | text-align: center; 112 | padding: 4px; 113 | color: #343434; 114 | font-size: 22px; 115 | font-weight: normal; 116 | text-transform: uppercase; 117 | font-family: 'Orienta', sans-serif; 118 | letter-spacing: 1px; 119 | font-style: italic; 120 | margin-bottom: 25px; 121 | """), 122 | string( 123 | name: 'kubernetes_repo_url', 124 | defaultValue: 'https://github.com/wso2/kubernetes-apim', 125 | description: "Product's kubernetes repository URL.", 126 | trim: true 127 | ), 128 | string( 129 | name: 'kubernetes_repo_branch', 130 | defaultValue: '4.1.x', 131 | description: 'Branch name of the kubernetes repository.', 132 | trim: true 133 | ), 134 | string( 135 | name: 'path_to_helm_folder', 136 | defaultValue: 'advanced/am-pattern-4', 137 | description: 'Relative path of the helm folder in your helm repository.', 138 | trim: true 139 | ), 140 | string( 141 | name: 'kubernetes_namespace', 142 | defaultValue: 'apim-4-1-0', 143 | description: 'namespace to be deployed.', 144 | trim: true 145 | ), 146 | separator(name: "TESTING ENVIRONMENT", sectionHeader: "Testing Details", 147 | separatorStyle: "border-width: 0", 148 | sectionHeaderStyle: """ 149 | background-color: #7ea6d3; 150 | text-align: center; 151 | padding: 4px; 152 | color: #343434; 153 | font-size: 22px; 154 | font-weight: normal; 155 | text-transform: uppercase; 156 | font-family: 'Orienta', sans-serif; 157 | letter-spacing: 1px; 158 | font-style: italic; 159 | margin-bottom: 25px; 160 | """), 161 | string( 162 | name: 'product_testing_repo_url', 163 | defaultValue: 'https://github.com/wso2/apim-test-integration', 164 | description: "Product's testing repository URL.", 165 | trim: true 166 | ), 167 | string( 168 | name: 'product_testing_repo_branch', 169 | defaultValue: '4.1.0-profile-automation', 170 | description: "Product's testing repository branch name.", 171 | trim: true 172 | ), 173 | string( 174 | name: 'test_file_path', 175 | defaultValue: './main.sh', 176 | description: 'Test execution relative file path', 177 | trim: true 178 | ), 179 | string( 180 | name: 'service_startup_timeout', 181 | defaultValue: '600', 182 | description: 'Service up timeout in seconds.', 183 | trim: true 184 | ) 185 | ]) 186 | ]) 187 | def lst = ["apim"]; 188 | if (!lst.contains(product_name)) { 189 | error("Product ${product_name} not supported"); 190 | } 191 | def cnfFolderName = "kubernetes/product-deployment/scripts/${product_name}" 192 | def kubernetesFolderName = "kubernetes/product-deployment/scripts/${product_name}/kubernetes-${product_name}" 193 | def testingFolderName = "kubernetes/product-deployment/scripts/${product_name}/test-${product_name}" 194 | dir(cnfFolderName) { 195 | git branch: "${deployment_script_repo_branch}", url: "${deployment_script_repo_url}" 196 | } 197 | dir(kubernetesFolderName) { 198 | deleteDir() 199 | git branch: "${kubernetes_repo_branch}", url: "${kubernetes_repo_url}" 200 | } 201 | dir(testingFolderName) { 202 | deleteDir() 203 | git branch: "${product_testing_repo_branch}", url: "${product_testing_repo_url}" 204 | } 205 | echo "workspace path : ${env.WORKSPACE} pwd: " 206 | sh "pwd" 207 | sh "chmod +x -R ${env.WORKSPACE}" 208 | } 209 | } 210 | } 211 | stage('Validate cluster') { 212 | steps { 213 | script { 214 | echo "\n\n\n\n==============================================" 215 | echo "Validate." 216 | echo "==============================================\n\n\n\n" 217 | withCredentials([[ 218 | $class: 'AmazonWebServicesCredentialsBinding', 219 | credentialsId: "testgrid-aws-kubernetes", 220 | accessKeyVariable: 'AWS_ACCESS_KEY_ID', 221 | secretKeyVariable: 'AWS_SECRET_ACCESS_KEY' 222 | ]]) { 223 | sh "./kubernetes/product-deployment/scripts/validate-cluster-and-params.sh" 224 | } 225 | } 226 | } 227 | } 228 | stage('Create Database') { 229 | steps { 230 | script { 231 | echo "\n\n\n\n==============================================" 232 | echo "Create RDS database." 233 | echo "==============================================\n\n\n\n" 234 | withCredentials([[ 235 | $class: 'AmazonWebServicesCredentialsBinding', 236 | credentialsId: "testgrid-aws-kubernetes", 237 | accessKeyVariable: 'AWS_ACCESS_KEY_ID', 238 | secretKeyVariable: 'AWS_SECRET_ACCESS_KEY' 239 | ]]) { 240 | sh "./kubernetes/product-deployment/scripts/create-database.sh" 241 | } 242 | } 243 | } 244 | } 245 | stage('Deploy into cluster') { 246 | steps { 247 | script { 248 | echo "\n\n\n\n==============================================" 249 | echo "Deploy ${product_name} into cluster" 250 | echo "==============================================\n\n\n\n" 251 | withCredentials([[ 252 | $class: 'AmazonWebServicesCredentialsBinding', 253 | credentialsId: "testgrid-aws-kubernetes", 254 | accessKeyVariable: 'AWS_ACCESS_KEY_ID', 255 | secretKeyVariable: 'AWS_SECRET_ACCESS_KEY' 256 | ]]) { 257 | sh "./kubernetes/product-deployment/scripts/deploy.sh ${product_name}" 258 | } 259 | } 260 | } 261 | } 262 | stage('Testing') { 263 | steps { 264 | script { 265 | echo "\n\n\n\n==============================================" 266 | echo "Testing ${product_name} into cluster" 267 | echo "==============================================\n\n\n\n" 268 | withCredentials([[ 269 | $class: 'AmazonWebServicesCredentialsBinding', 270 | credentialsId: "testgrid-aws-kubernetes", 271 | accessKeyVariable: 'AWS_ACCESS_KEY_ID', 272 | secretKeyVariable: 'AWS_SECRET_ACCESS_KEY' 273 | ]]) { 274 | hostName = sh( 275 | returnStdout: true, 276 | script: './kubernetes/product-deployment/scripts/extract-cluster-details.sh' 277 | ) 278 | sh "kubectl wait --for=condition=ready pod -l product='$product_name' --timeout='$service_startup_timeout's --namespace='$kubernetes_namespace'" 279 | env.HOST_NAME=hostName.trim() 280 | sh "./kubernetes/product-deployment/scripts/test.sh ${product_name} ${test_file_path}" 281 | } 282 | } 283 | } 284 | } 285 | } 286 | post { 287 | always { 288 | withCredentials([[ 289 | $class: 'AmazonWebServicesCredentialsBinding', 290 | credentialsId: "testgrid-aws-kubernetes", 291 | accessKeyVariable: 'AWS_ACCESS_KEY_ID', 292 | secretKeyVariable: 'AWS_SECRET_ACCESS_KEY' 293 | ]]) { 294 | echo "\n\n\n\n==============================================" 295 | echo "Uninstall ${product_name} in cluster" 296 | echo "==============================================\n\n\n\n" 297 | sh "./kubernetes/product-deployment/scripts/cleanup.sh ${product_name} || true" 298 | archiveArtifacts artifacts: "kubernetes/product-deployment/output/**/*.*", fingerprint: true 299 | script { 300 | sendEmail() 301 | } 302 | } 303 | 304 | cleanWs deleteDirs: true, notFailBuild: true 305 | } 306 | } 307 | } 308 | 309 | def sendEmail() { 310 | if (currentBuild.currentResult.equals("SUCCESS")){ 311 | headerColour = "#05B349" 312 | }else{ 313 | headerColour = "#ff0000" 314 | } 315 | content=""" 316 |
317 |
318 |
319 | 320 | 323 | 326 |
321 |

Kubernetes deployment test results

322 |
324 | 325 |
327 |
328 |

329 | 330 | Testgrid Kubernetes Deployment job status 331 | 332 |

333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 |
Test SpecificationTest Values
Product${product_name.toUpperCase()}
Version${product_version}
Database${db_engine}
Databases version${db_version}
359 |
360 |
361 |

362 | 363 | Build Info: 364 | ${BUILD_URL} 365 | 366 |

367 |
368 |
369 |
370 | Tested by WSO2 Jenkins TestGrid Kubernetes Deployment Pipeline. 371 |
372 | """ 373 | subject="[TestGrid][KubernetesDeployments][${product_name.toUpperCase()}:${product_version}]]-Build ${currentBuild.currentResult}-#${env.BUILD_NUMBER}" 374 | senderEmailGroup="" 375 | if(product_name.equals("apim")){ 376 | senderEmailGroup = "integration-builder@wso2.com" 377 | } 378 | emailext(to: "${senderEmailGroup}", 379 | subject: subject, 380 | body: content, mimeType: 'text/html') 381 | } 382 | --------------------------------------------------------------------------------