Ci for all

download Ci for all

If you can't read please download the document

Transcript of Ci for all

CI for ALL

Agenda

CI - Why, What & How

YAML file and JJB

CI Work-flow

Build triggers

Parameterize the jobs

Build jobs using JJB

Q&A session

Why CI?

Company Goal

Delay in response

Env issues & User errors

Inefficient use of tools/resources

Duplicate test reports

Compromise in Quality

What does CI do?

Automatic execution of tests

Integrate different tools

Latest & greatest pkgs

Clean env

TIER based runs

Centralized reporting

How to setup CI?

Jenkins Master/SlaveInstall/Config/Plugin

Requirements and project details YAML file

JJB Jenkins Job Builder

Triggers

Repo creation

Provision & teardown

Runtest

YAML file and JJB

YAML fileGlobal defaultsProject vars & JobsJenkins varsJson fileRestraint xmlBuildersParametersJobs

Jenkins JobsTriggerRepo creationProvisionRuntestTeardown

Build jobs from JenkinsJJB(Python script)

GIT repo

Jenkins Master

Config file(Creds)

CI work-flow

BrewTrigger

Provision ResourcesRuntestTeardownResourcesBrew buildFamilyArchTagVariantCI_NAMECI_TypeBrew-tag

Beaker taskTest suite

Redhat CIPluginYAML file

MailNotifications

IRC Notifications

JMS Selector

Brew bus

Jenkins Jobs

JJB

Project variables

jobs:
- '{prefix}-{testsuite}-{arch}-provision'
- '{prefix}-{testsuite}-{arch}-runtest'
- '{prefix}-{testsuite}-{arch}-teardown'

testsuite:
- test1
- test2
- test3

Prefix: rhds

brew-tag: rhel-7.2-candidate

arch: x86_64

Variables contd...

Replace variable with values:Variable within YAML file'{release}'

'{prefix}-{testsuite}-{arch}-provision'

Parameters$PATCH_ID

$BUILD_ID

Jenkins env variables$WORKSPACE

$JENKINS_HOME

Build triggers

Upstream job - Trigger

Downstream Provision

Triggers:
- ci-trigger:
jms-selector: |

CI_TYPE IN ('brew-tag')
AND
CI_NAME IN ('389-ds-base','nss','openldap')
AND
tag IN '{brew-tag}'

Build triggers contd...

Periodic build trigger

Jenkins job triggerBuild when jobs built

Build when jobs promoted

Build based on results of multiple jobs

Script trigger Shell script

Gerrit triggerGerrit server details

When patchset created, merged

Provision

Beaker/OpenstackJSON File

provision_resources.sh

Upstream job - Trigger

Downstream job - Runtest

Copy artifcatsInject information to RESOURCES.txt

Provision contd...

- builder:
name: 'provision-resources'
builders: - shell: |
#!/bin/bash $WORKSPACE/ci-ops-central/bootstrap/provision_resources.sh --site=$SITE \ --project_defaults=dirsrv-tests/config/project_defaults \ --topology={topology}-$PROVISIONER \ --ssh_keyfile=dirsrv-tests/config/keys/idm-jenkins \ --name={testsuite}TR_STATUS=$?

JSON File "family": "RedHatEnterpriseLinux7",
arch": "x86_64",
"tag": ["RTT_ACCEPTED"],
"variant": "Server",
"hostrequire": ["arch=x86_64"]

"name": "ci-ops-rhel-7-1",
"count": "1",
"flavor": "m1.medium",
"image": "RHEL-7.2-Server-x86_64-latest",
"ip": "10.8.60.20", "name": "nocp9.idm.lab.eng.rdu2.redhat.com", "private_ip": "10.8.60.20

Runtest

Restraint xml fileBeaker task

Install, configure and execute tests

AnsibleAnsible playbook

Install pkgs

Run your tests

Upstream provisionBkr job ID, IP address & Hostname

Downstream - teardown

Config file

[jenkins]user=idm-jenkinspassword=Secret123url=https://idm-qe-jenkins.rhev-ci-vms.eng.rdu2.redhat.comignore_cache=False

Jenkins Job Builder

builders: - shell: | JENKINS_URL=${JENKINS_URL:-"https://localhost/"}
pushd $WORKSPACE/dirsrv-tests Popd

cd $WORKSPACE

python -m jenkins_jobs.cmd --conf $WORKSPACE/$CONIG_FILE --flush-cache update $WORKSPACE/$GIT_REPO/$CI_DIR

Example for RHDS: python -m jenkins_jobs.cmd --conf $WORKSPACE/dirsrv-tests/jobs/config --flush-cache update $WORKSPACE/dirsrv-tests/jobs/rhel72

Parameterize jobs

Change variable valuesTroubleshooting & Manual execution

choice:
name: tag
choices:
- rhel-7.2-z-candidate
- rhel-7.2-candidate
description: "Brew tag for this build."

string:
name: REPORT_EMAIL
default: [email protected]
description: Default email id for reports

JJB with Gerrit refspec

Add a parameter - GERRIT_REFSPEC

Add a build step Execute shell

pushd $WORKSPACE/dirsrv-tests
git pull
https://code.engineering.redhat.com/gerrit/dirsrv-tests
$GERRIT_REFSPEC
popdcd $WORKSPACE

python -m jenkins_jobs.cmd --conf $WORKSPACE/dirsrv-tests/jobs/config --flush-cache update $WORKSPACE/dirsrv-tests/jobs/$GIT_BRANCH

References

About CI in MOJO - https://mojo.redhat.com/search.jspa?q=CI%20workflowSetup CI with Jenkins - http://www.vogella.com/tutorials/Jenkins/article.htmlJenkins CI plugin - https://mojo.redhat.com/docs/DOC-986839CI Reference guide - https://mojo.redhat.com/docs/DOC-1030059

Questions