├── vars ├── copy.txt ├── executeTests.txt ├── log.txt ├── unmountEFS.txt ├── getAvailabilityZone.txt ├── writeEFSIP.txt ├── mountEFS.txt ├── buildArtifacts.txt ├── cloneRepoToDir.txt ├── copyArtifacts.txt ├── deployAWSNetwork.txt ├── buildImage.txt ├── applyConfig.txt ├── log.groovy ├── getAvailabilityZone.groovy ├── deployAWSNetwork.groovy ├── deployAWS.txt ├── cloneRepoToDir.groovy ├── deployAWSProd.txt ├── executeTests.groovy ├── copy.groovy ├── buildArtifacts.groovy ├── unmountEFS.groovy ├── writeEFSIP.groovy ├── copyArtifacts.groovy ├── mountEFS.groovy ├── buildImage.groovy ├── deployAWS.groovy ├── deployAWSProd.groovy └── applyConfig.groovy ├── .gitignore ├── issue_template.md ├── README.md ├── pull_request_template.md ├── src └── org │ └── wso2 │ └── util │ └── Constants.groovy └── LICENSE /vars/copy.txt: -------------------------------------------------------------------------------- 1 |
4 | Copy provided source directory to the destination 5 |
6 | 7 |10 | Below is an example how you can use "cp" 11 |
12 | 13 |14 |
15 | @Library('wso2-pipeline-core')
16 | cp ([src: "src", dest: "dest"])
17 |
18 |
19 |
--------------------------------------------------------------------------------
/vars/executeTests.txt:
--------------------------------------------------------------------------------
1 | executeTests
2 |
3 |
4 | Execute a shell script
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "executeTests".
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | executeTests "./testScript.sh"
17 |
18 |
--------------------------------------------------------------------------------
/vars/log.txt:
--------------------------------------------------------------------------------
1 | log
2 |
3 |
4 | Out put a message to standard output
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "log".
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | log.info "Testing"
17 | log.err "Error"
18 |
19 |
--------------------------------------------------------------------------------
/vars/unmountEFS.txt:
--------------------------------------------------------------------------------
1 | unmountEFS
2 |
3 |
4 | Unmount a given EFS
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "unmountEFS"
11 |
12 |
13 |
14 |
15 |
16 | @Library('wso2-jenkins-shared-lib')
17 | unmountEFS([mountPoint : "${EFS_MOUNT}"])
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/vars/getAvailabilityZone.txt:
--------------------------------------------------------------------------------
1 | getAvailabilityZone
2 |
3 |
4 | Get the availability zone of the this instance. Only works in a AWS EC2 environment
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "getAvailabilityZone"
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | getAvailabilityZone()
17 |
18 |
19 |
--------------------------------------------------------------------------------
/vars/writeEFSIP.txt:
--------------------------------------------------------------------------------
1 | writeEFSIP
2 |
3 |
4 | Write a value to jenkins environment file
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "writeEFSIP"
11 |
12 |
13 |
14 |
15 |
16 | @Library('wso2-jenkins-shared-lib')
17 | writeEFSIP([efsIdentifier: "${PROD_EFS_IDENTIFIER}",
18 | MountTargetIP: "${outputs.MountTargetIP}"])
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vars/mountEFS.txt:
--------------------------------------------------------------------------------
1 | mountEFS
2 |
3 |
4 | Mount a given EFS using IP to desired directory
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "mountEFS"
11 |
12 |
13 |
14 |
15 |
16 | @Library('wso2-jenkins-shared-lib')
17 | mountEFS([mountPoint : "${EFS_MOUNT}",
18 | efsIp : "${EFS_IDENTIFIER}",
19 | region : "${env.REGION}"])
20 |
21 |
22 |
--------------------------------------------------------------------------------
/vars/buildArtifacts.txt:
--------------------------------------------------------------------------------
1 | buildArtifacts
2 |
3 |
4 | Build artifacts from Source Code
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "buildIArtifacts"
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | buildArtifacts ([artifactLoc : "artifactLoc",
17 | image_resources : "image_resources",
18 | artifactConf : "artifactConf")
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vars/cloneRepoToDir.txt:
--------------------------------------------------------------------------------
1 | cloneRepoToDir
2 |
3 |
4 | Clone a Git repository to a specific directory. By default master branch is cloned.
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "cloneRepoToDir"
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | cloneRepoToDir ([ repoUrl : "repoUrl",
17 | directory : "directory",
18 | credID : "credID" ])
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vars/copyArtifacts.txt:
--------------------------------------------------------------------------------
1 | copyArtifacts
2 |
3 |
4 | Copy contents in a directory to another location
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "copyArtifacts"
11 |
12 |
13 |
14 |
15 |
16 | @Library('wso2-jenkins-shared-lib')
17 | copyArtifacts ([image_resources:"${ARTIFACTS_DIR_LOC}",
18 | mountDir :"${DEPLOYMENT_DIR}","
19 | mountPoint :"${EFS_MOUNT}"])
20 |
21 |
22 |
--------------------------------------------------------------------------------
/vars/deployAWSNetwork.txt:
--------------------------------------------------------------------------------
1 | deployAWSNetwork
2 |
3 |
4 | Deploy provided CFN on AWS.
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "deployAWSNetwork". This will return the required VPC ID from the output.
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | deployAWSNetwork([stackName : "stackName",
17 | cf : "cf",
18 | TransitGatewayId: "TransitGatewayId",
19 | vpcID : "vpcID"])
20 |
21 |
--------------------------------------------------------------------------------
/vars/buildImage.txt:
--------------------------------------------------------------------------------
1 | buildImage
2 |
3 |
4 | Build an immutable image
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "buildImage"
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | buildImage ([product : "product",
17 | version : "version",
18 | deploymentPattern : "deploymentPattern",
19 | region : "region",
20 | dbType : "dbType"
21 | packerJson : "packerjson",
22 | imageResources : "imageResources"
23 | packerManifest : "packermanifest")
24 |
25 |
26 |
--------------------------------------------------------------------------------
/vars/applyConfig.txt:
--------------------------------------------------------------------------------
1 | applyConfig
2 |
3 |
4 | Apply Build configurations to the pack.
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "applyConfig"
11 |
12 |
13 |
14 |
15 |
16 | @Library('wso2-jenkins-shared-lib')
17 | applyConfig(product : "product",
18 | version : "version",
19 | deploymentPattern : "deploymentPattern}",
20 | wum_creds : "wum_creds",
21 | puppetManifest : "puppetManifest",
22 | artifactsLoc : "artifactsLoc",
23 | zipLoc : "zipLoc",
24 | wumHome : "wumHome",
25 | puppetConfLoc : "puppetConfLoc"]
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 |
--------------------------------------------------------------------------------
/vars/log.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | def err(msg) {
20 | ansiColor('xterm') {
21 | echo "\u001B[31mERROR: $msg"
22 | }
23 | }
24 | def info(msg) {
25 | ansiColor('xterm') {
26 | echo "\u001B[36mINFO: $msg"
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/vars/getAvailabilityZone.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | String call() {
20 | return sh(
21 | script: '''
22 | set +x
23 | ec2metadata --availability-zone | sed \'s/[a-z]$//\'
24 | ''',
25 | returnStdout: true
26 | ).trim()
27 | }
28 |
--------------------------------------------------------------------------------
/vars/deployAWSNetwork.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2019, 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 | def call(Map config) {
20 | def TransitGatewayId = "TransitGatewayId=${config.TransitGatewayId}"
21 | cfnUpdate(stack: "${config.stackName}", file: "${config.cf}",
22 | params: [TransitGatewayId]
23 | , timeoutInMinutes: 30, pollInterval: 1000)
24 | }
25 |
--------------------------------------------------------------------------------
/vars/deployAWS.txt:
--------------------------------------------------------------------------------
1 | deployAWS
2 |
3 |
4 | Deploy provided CFN on AWS.
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "deployAWS". This will return the required Test endpoint from the output.
11 |
12 |
13 |
14 |
15 | @Library('wso2-jenkins-shared-lib')
16 | deployAWS([wso2InstanceType: "wso2InstanceType",
17 | product : "product",
18 | version : "version",
19 | keyPairName : "keyPairName",
20 | certName : "certName",
21 | dbCredID : "dbCredID",
22 | dbType : "dbType",
23 | amiID : "amiID",
24 | iamRole : "iamRole",
25 | region : "region",
26 | stackName : "stackName",
27 | cf : "cf",
28 | testEndpoint : "testEndpoint",
29 | environment : "environment"])
30 |
31 |
--------------------------------------------------------------------------------
/vars/cloneRepoToDir.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | def call(Map config) {
21 | dir(config.directory) {
22 | checkout([$class : 'GitSCM', branches: [[name: config.branch]], doGenerateSubmoduleConfigurations: false,
23 | extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: config.credID, url: config.repoUrl]]])
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/vars/deployAWSProd.txt:
--------------------------------------------------------------------------------
1 | deployAWSProd
2 |
3 |
4 | Deploy provided production CFN on AWS.
5 |
6 |
7 | How to use
8 |
9 |
10 | Below is an example how you can use "deployAWSProd"
11 |
12 |
13 |
14 |
15 |
16 | @Library('wso2-jenkins-shared-lib')
17 | deployAWSProd([wso2InstanceType: "${env.WSO2InstanceType}",
18 | product : "${PRODUCT}",
19 | version : "${VERSION}",
20 | keyPairName : "${env.KeyPairName}",
21 | certName : "${env.CertificateName}",
22 | dbCredID : "${DB_CREDS}",
23 | dbType : "${env.DBType}",
24 | amiID : "${env.IMAGE_ID}",
25 | iamRole : "${env.IAMRole}",
26 | region : "${env.REGION}",
27 | stackName : "${STACK_PROD}",
28 | cf : "${PROD_CF}",
29 | environment : "${PROD}",
30 | TransitGatewayId: "${env.TransitGatewayId}"])
31 |
32 |
33 |
--------------------------------------------------------------------------------
/vars/executeTests.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | import org.wso2.util.Constants
20 |
21 | def call(script) {
22 | withEnv(["script=${script}"]) {
23 | int status = sh(
24 | script: '''
25 | set +x
26 | ${script}
27 | ''',
28 | returnStatus: true
29 | )
30 |
31 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
32 | throw new Exception("Test script failed")
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vars/copy.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | import org.wso2.util.Constants
20 |
21 | def call(Map config) {
22 | withEnv(["SRC=${config.src}", "DEST=${config.dest}"]) {
23 | int status = sh(
24 | script: '''
25 | cp -r ${SRC} ${DEST}
26 | ''',
27 | returnStatus: true
28 | )
29 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
30 | throw new Exception("Copying failed. Source: ${config.src}, Destination: ${config.dest}")
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vars/buildArtifacts.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 |
3 | /*
4 | * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
5 | *
6 | * WSO2 Inc. licenses this file to you under the Apache License,
7 | * Version 2.0 (the "License"); you may not use this file except
8 | * in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | */
20 |
21 | import org.wso2.util.Constants
22 |
23 | def call(Map config) {
24 | withEnv(["ARTIFACT_LOC=${config.artifactsLoc}",
25 | "IMAGE_RESOURCES=${config.image_resources}"]) {
26 |
27 | int status = sh(
28 | script: "${config.artifactConf}",
29 | returnStatus: true
30 | )
31 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
32 | throw new Exception("Failed to build the artifacts")
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vars/unmountEFS.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | import org.wso2.util.Constants
20 |
21 | def call(Map config) {
22 | withEnv(["MOUNT_POINT=${config.mountPoint}"]) {
23 | int status = sh(
24 | script: '''
25 | if grep -qs ${MOUNT_POINT} /proc/mounts; then
26 | sudo umount ${MOUNT_POINT}
27 | else
28 | echo "Already unmounted"
29 | fi
30 | ''',
31 | returnStatus: true
32 | )
33 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
34 | throw new Exception("Unmount failed")
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/vars/writeEFSIP.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 |
3 | /*
4 | * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
5 | *
6 | * WSO2 Inc. licenses this file to you under the Apache License,
7 | * Version 2.0 (the "License"); you may not use this file except
8 | * in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | */
20 |
21 | import org.wso2.util.Constants
22 |
23 | def call(Map config) {
24 | withEnv(["EFS_IP_IDENTIFIER=${config.efsIdentifier}",
25 | "EFS_IP=${config.MountTargetIP}"]) {
26 |
27 | int status = sh(
28 | script: '''
29 | sed -i "s/.*${EFS_IP_IDENTIFIER}.*'/env.${EFS_IP_IDENTIFIER}=\'${EFS_IP}\'/g" /home/jenkins/jenkins_env
30 | ''',
31 | returnStatus: true
32 | )
33 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
34 | throw new Exception("Failed to build the artifacts")
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/vars/copyArtifacts.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2019, 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 | import org.wso2.util.Constants
20 |
21 | def call(Map config) {
22 | withEnv(["SOURCE_ARTIFACTS=${config.image_resources}", "MOUNT_POINT=${config.mountPoint}", "MOUNT_DIR=${config.mountDir}"]) {
23 | int status = sh(
24 | script: '''
25 | sudo mkdir -p ${MOUNT_POINT}/deployment/server/${MOUNT_DIR}
26 | sudo cp ${SOURCE_ARTIFACTS}/* ${MOUNT_POINT}/deployment/server/${MOUNT_DIR}/
27 | ''',
28 | returnStatus: true
29 | )
30 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
31 | throw new Exception("Mounting Failed")
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/vars/mountEFS.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2019, 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 | import org.wso2.util.Constants
20 |
21 | def call(Map config) {
22 | withEnv(["MOUNT_POINT=${config.mountPoint}", "EFS_IP=${config.efsIp}", "REGION=${config.region}"]) {
23 | int status = sh(
24 | script: '''
25 | sudo mkdir -p ${MOUNT_POINT}
26 | if grep -qs ${MOUNT_POINT} /proc/mounts; then
27 | echo "Already mounted."
28 | else
29 | sudo mount -t nfs4 -o nfsvers=4.1 ${EFS_IP}:/ ${MOUNT_POINT}
30 | fi
31 | ''',
32 | returnStatus: true
33 | )
34 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
35 | throw new Exception("Mount failed")
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Shared resources in AWS CICD Pipeline
2 | > **Warning**
3 | >
4 | > The CICD pipeline is deprecated.
5 | >
6 |
7 | This repository contains the library resources used in AWS Pipeline. [Jenkins shared library](https://github.com/wso2/aws-cicd-shared-lib.git) contains set of functions used in [Jenkins pipeline artifacts](https://github.com/wso2/aws-cicd-pipeline.git).
8 |
9 |
10 | #### Prerequisites
11 | This library depends on following Jenkins plugins:
12 |
13 | * [AnsiColor plugin](https://wiki.jenkins.io/display/JENKINS/AnsiColor+Plugin)
14 | * [Pipeline AWS Plugin](https://wiki.jenkins.io/display/JENKINS/Pipeline+AWS+Plugin)
15 | * [Pipeline Utility Steps Plugin](https://wiki.jenkins.io/display/JENKINS/Pipeline+Utility+Steps+Plugin)
16 |
17 |
18 | #### Quick Start Guide
19 |
20 | **Step 1**: Configure this repository as a shared library under the name "wso2-jenkins-shared-lib"
21 |
22 | **Step 2**: Use the functions under vars folder. Refer the text files for each function for samples.
23 |
24 | * [applyConfig](vars/applyConfig.groovy)
25 | * [buildArtifacts](vars/buildArtifacts.groovy)
26 | * [buildImage](vars/buildImage.groovy)
27 | * [cloneRepotoDir](vars/cloneRepotoDir.groovy)
28 | * [copy](vars/copy.groovy)
29 | * [copyArtifacts](vars/copyArtifacts.groovy)
30 | * [deployAWS](vars/deployAWS.groovy)
31 | * [deployAWSNetwork](vars/deployAWSNetwork.groovy)
32 | * [deployAWSProd](vars/deployAWSProd.groovy)
33 | * [executeTests](vars/executeTests.groovy)
34 | * [getAvailabilityZone](vars/getAvailabilityZone.groovy)
35 | * [log](vars/log.groovy)
36 | * [mountEFS](vars/mountEFS.groovy)
37 | * [unmountEFS](vars/unmountEFS.groovy)
38 | * [writeEFSIP](vars/writeEFSIP.groovy)
--------------------------------------------------------------------------------
/vars/buildImage.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | import org.wso2.util.Constants
20 |
21 | String call(Map config) {
22 | withEnv(["PRODUCT=${config.product}",
23 | "VERSION=${config.version}",
24 | "DEPLOYMENTPATTERN=${config.deploymentPattern}",
25 | "DBTYPE=${config.dbType}",
26 | "PACKER_REGION=${config.region}",
27 | "PACKER_JSON=${config.packerJson}",
28 | "PACKER_MANIFEST=${config.packerManifest}",
29 | "AMI_NAME=${config.amiName}",
30 | "IMAGE_RESOURCES=${config.imageResources}"]) {
31 | int status = sh(
32 | script: """
33 | packer build -var "product=$PRODUCT" \
34 | -var "version=$VERSION" \
35 | -var "deploymentPattern=$DEPLOYMENTPATTERN" \
36 | -var "dbType=$DBTYPE" \
37 | -var "region=$PACKER_REGION" \
38 | -var "image_resources=$IMAGE_RESOURCES" \
39 | -var "amiName=$AMI_NAME" \
40 | -var "manifest=$PACKER_MANIFEST" $PACKER_JSON
41 | """,
42 | returnStatus: true
43 | )
44 | if (status != Constants.ControlConstants.STATUS_COMPLETED) {
45 | throw new Exception("AMI building is failed !")
46 | }
47 | def packer_post = readJSON file: "${config.packerManifest}", text: ''
48 | def size = packer_post.builds.artifact_id.size()
49 | def ami_info = packer_post.builds.artifact_id[size - 1]
50 | def (value1, value2) = "$ami_info".tokenize(':')
51 | return value2
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/vars/deployAWS.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | def call(Map config) {
20 | def WSO2InstanceType = "WSO2InstanceType=${config.wso2InstanceType}"
21 | def KeyPairName = "KeyPairName=${config.keyPairName}"
22 | def CertificateName = "CertificateName=${config.certName}"
23 | def DBType = "DBType=${config.dbType}"
24 | def AMIId = "AMIid=${config.amiID}"
25 | def Product = "Product=${config.product}"
26 | def Version = "Version=${config.version}"
27 | def Environment = "Environment=${config.environment}"
28 | def IAMRole = "IAMRole=${config.iamRole}"
29 | def NetworkStackName = "NetworkStackName=${config.networkStackName}"
30 | withCredentials([[$class : 'UsernamePasswordMultiBinding',
31 | credentialsId : "${config.dbCredID}",
32 | usernameVariable : 'DBUsername',
33 | passwordVariable : 'DBPassword']]) {
34 | def DBUsername = "DBUsername=$DBUsername"
35 | def DBPassword = "DBPassword=$DBPassword"
36 | withAWS(role:"${config.iamRole}", region: "${config.region}") {
37 | def outputs = cfnUpdate(stack: "${config.stackName}", file: "${config.cf}",
38 | params: [IAMRole,
39 | WSO2InstanceType,
40 | KeyPairName,
41 | CertificateName,
42 | DBUsername,
43 | DBPassword,
44 | DBType,
45 | AMIId,
46 | Product,
47 | Version,
48 | Environment,
49 | NetworkStackName]
50 | , timeoutInMinutes: 30, pollInterval: 1000)
51 | return outputs
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/vars/deployAWSProd.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 | /*
3 | * Copyright (c) 2018, 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 | def call(Map config) {
20 | def WSO2InstanceType = "WSO2InstanceType=${config.wso2InstanceType}"
21 | def KeyPairName = "KeyPairName=${config.keyPairName}"
22 | def CertificateName = "CertificateName=${config.certName}"
23 | def DBType = "DBType=${config.dbType}"
24 | def AMIId = "AMIid=${config.amiID}"
25 | def Product = "Product=${config.product}"
26 | def Version = "Version=${config.version}"
27 | def Environment = "Environment=${config.environment}"
28 | def IAMRole = "IAMRole=${config.iamRole}"
29 | def TransitGatewayId = "TransitGatewayId=${config.TransitGatewayId}"
30 | withCredentials([[$class : 'UsernamePasswordMultiBinding',
31 | credentialsId : "${config.dbCredID}",
32 | usernameVariable : 'DBUsername',
33 | passwordVariable : 'DBPassword']]) {
34 | def DBUsername = "DBUsername=$DBUsername"
35 | def DBPassword = "DBPassword=$DBPassword"
36 | withAWS(role:"${config.iamRole}", region: "${config.region}") {
37 | def outputs = cfnUpdate(stack: "${config.stackName}", file: "${config.cf}",
38 | params: [IAMRole,
39 | WSO2InstanceType,
40 | KeyPairName,
41 | CertificateName,
42 | DBUsername,
43 | DBPassword,
44 | DBType,
45 | AMIId,
46 | Product,
47 | Version,
48 | Environment,
49 | TransitGatewayId]
50 | , timeoutInMinutes: 30, pollInterval: 1000)
51 | return outputs
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/src/org/wso2/util/Constants.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 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 | package org.wso2.util
19 |
20 | /**
21 | * This class holds constants
22 | */
23 | class Constants {
24 | class ControlConstants {
25 | static final int STATUS_COMPLETED = 0
26 | static final int STATUS_FAILED_WUM_UPDATE = 10
27 | static final int STATUS_FAILED_WUM_ADD = 11
28 | static final int STATUS_FAILED_INPLACE_UPDATES = 12
29 | static final int STATUS_FAILED_PUPPET_APPLY = 13
30 | static final int STATUS_FAILED_TO_MOVE_UPDATED_PRODUCT = 14
31 | static final int STATUS_FAILED_UNZIP = 15
32 | static final int STATUS_FAILED_RM_UNZIP = 16
33 | static final int STATUS_FAILED_ARTIFACT_APPLY = 17
34 | static final int STATUS_FAILED_WUM_INIT = 18
35 | static final int STATUS_FAILED_DOWNLOAD_PACK = 19
36 | static final int STATUS_FAILED_DOWNLOAD_PATCH_FILE=20
37 | }
38 | class Stages {
39 | static final String SETUP_ENV = "Setup Environment"
40 | static final String BUILD_PACK = "Build the pack"
41 | static final String BUILD_IMAGE = "Build the immutable image"
42 | static final String DEPLOY_DEV = "Deploy to Development"
43 | static final String APPROVE_STAGING = "Approve Staging"
44 | static final String DEPLOY_STAGING = "Deploy to Staging"
45 | static final String RUNNING_TESTS = "Running Tests"
46 | static final String APPROVE_PRODUCTION = "Approve Production"
47 | static final String DEPLOY_PRODUCTION = "Deploy to Production"
48 | static final String BUILD_ARTIFACTS = "Build artifacts"
49 | static final String DEPLOY_NETWORK = "Deploy Network Resources"
50 | static final String CLONE_ARTIFACT_SOURCE = "Clone artifact source repository"
51 | static final String MOUNT_EFS = "Mount EFS"
52 | static final String COPY_ARTIFACTS = "Copy artifacts to EFS"
53 | static final String UNMOUNT_EFS= "Unmount EFS"
54 | static final String WRITE_EFS_IP = "Write EFS IP"
55 | static final String ROLLBACK = "Rollback environment"
56 |
57 | }
58 | class Paths {
59 | static final String RESOURCES = "/home/jenkins/resources"
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/vars/applyConfig.groovy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env groovy
2 |
3 | /*
4 | * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
5 | *
6 | * WSO2 Inc. licenses this file to you under the Apache License,
7 | * Version 2.0 (the "License"); you may not use this file except
8 | * in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | */
20 |
21 | import org.wso2.util.Constants
22 |
23 | def call(Map config) {
24 | withEnv(["ARTIFACT_LOC=${config.artifactsLoc}",
25 | "ZIP_OUTPUT_LOC=${config.zipLoc}",
26 | "WUM_HOME=${config.wumHome}",
27 | "PUPPET_CONF_LOC=${config.puppetConfLoc}",
28 | "DEPLOYMENT_PATTERN=${config.deploymentPattern}",
29 | "PRODUCT=${config.product}",
30 | "VERSION=${config.version}"]) {
31 |
32 | withCredentials([usernamePassword(credentialsId: "${config.wum_creds}",
33 | passwordVariable: 'WUM_PASSWORD',
34 | usernameVariable: 'WUM_USERNAME')]) {
35 | int status = sh(
36 | script: "${config.puppetManifest}",
37 | returnStatus: true
38 | )
39 | if (status == Constants.ControlConstants.STATUS_FAILED_WUM_UPDATE) {
40 | throw new Exception("Failed to apply updates")
41 | } else if (status == Constants.ControlConstants.STATUS_FAILED_WUM_INIT) {
42 | throw new Exception("Failed to init WUM. Check your WUM credentials")
43 | } else if (status == Constants.ControlConstants.STATUS_FAILED_WUM_ADD) {
44 | throw new Exception("Wum add process failed")
45 | } else if (status == Constants.ControlConstants.STATUS_FAILED_INPLACE_UPDATES) {
46 | throw new Exception("Inplace update process failed")
47 | } else if (status == Constants.ControlConstants.STATUS_FAILED_PUPPET_APPLY) {
48 | throw new Exception("Puppet apply process failed")
49 | } else if (status == Constants.ControlConstants.STATUS_FAILED_TO_MOVE_UPDATED_PRODUCT) {
50 | throw new Exception("Failed to move updated pack")
51 | } else if (status == Constants.ControlConstants.STATUS_FAILED_UNZIP) {
52 | throw new Exception("Failed to unzip")
53 | } else if (status == Constants.ControlConstants.STATUS_FAILED_RM_UNZIP) {
54 | throw new Exception("Failed to remove zip")
55 | } else if (status == Constants.ControlConstants.STATUS_FAILED_ARTIFACT_APPLY) {
56 | throw new Exception("Failed to apply artifatcs")
57 | } else if (status == Constants.ControlConstants.STATUS_FAILED_DOWNLOAD_PACK) {
58 | throw new Exception("Failed to download product pack from S3 bucket")
59 | } else if(status == Constants.ControlConstants.STATUS_FAILED_DOWNLOAD_PATCH_FILE) {
60 | throw new Exception("Failed to download the patch file from S3 bucket")
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------