From a1822f0905f418f56878bb1c2bb60f52b60a261f Mon Sep 17 00:00:00 2001 From: Cara Wang Date: Jun 19 2020 03:10:33 +0000 Subject: add c3i-ansible files --- diff --git a/openshift/README.md b/openshift/README.md new file mode 100644 index 0000000..ff48d8c --- /dev/null +++ b/openshift/README.md @@ -0,0 +1,20 @@ +# WaiverDB on OpenShift + +This directory contains documents and OpenShift manifests for WaiverDB OpenShift deployments +and CI/CD automation on top of OpenShift. + +## What do you want? + +- Build and deploy a WaiverDB container manually + - [Build a WaiverDB container locally](docs/build-waiverdb-container.md) + - [Deploy a WaiverDB container to OpenShift manually](docs/deploy-waiverdb-container.md) +- Build, test, and deploy a WaiverDB container with WaiverDB C3I Pipeline (using CI/CD approach) + - [Build and test a pull-request with WaiverDB C3I pipeline](docs/pipeline-build-and-test-pr.md) + - [Build and test a Git branch with WaiverDB C3I pipeline](docs/pipeline-build-and-test-branch.md) + - [Test a WaiverDB container with WaiverDB C3I pipeline](docs/pipeline-test-image.md) + - [Deploy a WaiverDB container to dev environment](docs/pipeline-deploy-to-dev.md) + - [Promote a WaiverDB container to stage or prod environment](docs/pipeline-promote-to-stage-or-prod.md) + - [Fix broken WaiverDB C3I pipeline](docs/pipeline-fix-broken-build.md) +- Advanced topics about WaiverDB C3I pipeline + - [WaiverDB C3I Pipeline Introduction](https://docs.google.com/a/redhat.com/document/d/e/2PACX-1vR11OgAmBRF1_Lprs8hpgchNodMb9sh1QKCO6t61JaGYs7UpBcsBJSQW_G7fqrwuRLBQPDrDbwKUtek/pub): See how WaiverDB C3I Pipeline works. + - [Deploy WaiverDB C3I pipeline (not WaiverDB app) to OpenShift](docs/pipeline-deployment.md) diff --git a/openshift/pipelines/c3i-role-vars.yml b/openshift/pipelines/c3i-role-vars.yml new file mode 100644 index 0000000..6ce9bc5 --- /dev/null +++ b/openshift/pipelines/c3i-role-vars.yml @@ -0,0 +1,10 @@ +c3i_component: testing_c3i_libary +c3i_build_and_test_snippet: snippets/testing-build-test.groovy +c3i_build_agent_snippet: snippets/build-agent.groovy + +c3i_mail_address: wlin@redhat.com + +c3i_jenkins_test_agent_image: docker-registry.upshift.redhat.com/factory2/factory2-integration-test-jenkins-slave:latest + +c3i_lib_url: https://pagure.io/c3i-library.git +c3i_lib_branch: master diff --git a/openshift/pipelines/deploy.yml b/openshift/pipelines/deploy.yml new file mode 100644 index 0000000..81fe7c8 --- /dev/null +++ b/openshift/pipelines/deploy.yml @@ -0,0 +1,15 @@ +- name: Deplomyent playbook + hosts: localhost + vars_files: + - c3i-role-vars.yml + tasks: + - git: + repo: "{{ c3i_lib_url }}" + dest: c3i-library + version: "{{ c3i_lib_branch }}" + - file: + src: c3i-library/roles + dest: roles + state: link + - include_role: + name: c3i diff --git a/openshift/pipelines/snippets/build-agent.groovy b/openshift/pipelines/snippets/build-agent.groovy new file mode 100644 index 0000000..914629b --- /dev/null +++ b/openshift/pipelines/snippets/build-agent.groovy @@ -0,0 +1,31 @@ +agent { + kubernetes { + cloud params.OPENSHIFT_CLOUD_NAME + label "jenkins-slave-${UUID.randomUUID().toString()}" + serviceAccount params.JENKINS_AGENT_SERVICE_ACCOUNT + defaultContainer 'jnlp' + yaml """ + apiVersion: v1 + kind: Pod + metadata: + labels: + app: "jenkins-${env.JOB_BASE_NAME}" + spec: + containers: + - name: jnlp + image: "${params.JENKINS_AGENT_IMAGE}" + imagePullPolicy: Always + tty: true + env: + - name: USER_NAME + value: jenkins + resources: + requests: + memory: 768Mi + cpu: 300m + limits: + memory: 1Gi + cpu: 500m + """ + } +} diff --git a/openshift/pipelines/snippets/testing-build-test.groovy b/openshift/pipelines/snippets/testing-build-test.groovy new file mode 100644 index 0000000..0b6d782 --- /dev/null +++ b/openshift/pipelines/snippets/testing-build-test.groovy @@ -0,0 +1,37 @@ +stage('Step 1 - Prepare') { + steps { + echo 'step 1' + } + } + } +} +stage('Step 2 - Check') { + failFast false + parallel { + stage('Parallel 1') { + steps { + sh 'echo parallel-1' + } + } + stage('Parallel 2') { + steps { + sh 'echo parallel-2' + } + } + } +} +stage('Step 3 - Testing') { + steps { + sh 'echo run testing' + } +} +stage('Build container') { + steps { + echo "Create templates with parameters, build container and push to the repo" + } +} +stage("Functional tests phase") { + steps { + echo "Container image will be tested." + } +}