Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mastering hordes of CI jobs using Jenkins plugins

Mastering hordes of CI jobs using Jenkins plugins

Jenkins plugins provide ability to automate CI test automation jobs creation (using Pipeline plugin and Job plugin) and this allows to effectively create and maintain lots of test automation configurations

Vjacheslav Lukashevich

September 19, 2019
Tweet

More Decks by Vjacheslav Lukashevich

Other Decks in Programming

Transcript

  1. ABOUT ME v I am a Tester v Studied Test

    Automation extensively v Worked on a number of great projects with Test Automation v Coaching and Teaching v Co-organiser of Riga Test Automation Club 2
  2. LOTS OF TEST AUTOMATION! v Tests for all products v

    Bots for performance testing v Infrastructure to run it v Cloud and Physical environments v CI/CD pipelines v Monitoring, alerting and analytics 4
  3. Payments smoke tests on UAT Job/Project Build Execution on 17.01.2018

    https://jenkins.io/doc/book/glossary Build 8 Result of Job execution
  4. Payments smoke tests on UAT Job/Project Build Pipeline Stage Step

    Execution on 17.01.2018 Smoke test pipeline • Prepare environment • Run tests • Report • Generate report • Run Maven build • Create directory to store results • Execute shell command https://jenkins.io/doc/book/glossary Pipeline-Stage-Step 9
  5. Payments smoke tests on UAT Job/Project Build Pipeline Stage Step

    Execution on 17.01.2018 Smoke test pipeline • Prepare environment • Run tests • Report • Generate report • Run Maven build • Create directory to store results • Execute shell command https://jenkins.io/doc/book/glossary Node/Agent • Machine capable to execute pipeline steps • Unix box • Docker container Agent 1 0
  6. vGet agent where to run tests vPull Test Code from

    GIT vBuild it vRun Tests using provided parameters vReport results Here comes most of the differences! Common Testing Pipeline Stages/Steps 11
  7. 12

  8. v Lots of input fields to enter in Jenkins forms

    v Adjusting existing jobs v Migrate to new Java version.. v Creating new jobs 13 Lot of work to configure and maintain jobs
  9. Groovy v Jenkins supported language v Yet another “Java like”

    language to learn v Data types v Strings v Lists, Maps v Functions, Closures v Work with JSON 17
  10. v Can be stored in GIT v Can be pasted

    as Code Pipeline scripts 18
  11. v Store in GIT v Reuse across similar jobs v

    Java regression tests jobs v TypeScript visual regression jobs for merge requests v … v GIT power! v Merge Requests v Code reviews v Change history What can we do with pipelines 1 9
  12. 22

  13. 1) Create function to reuse across different pipelines 2) Use

    it in pipeline script 23 Creating Library
  14. v Custom reporting v Slack bots v Gitlab comments v

    Parsing of Allure reports (failures, errors) v Storing test results in DB for visualization v Triggering jobs in parallel v Pre-building test artifacts v Creating test environments Libraries we have 24
  15. 1) Create job with some name 2) Specify Build Triggers

    conditions 3) Provide additional parameters 4) Specify Pipeline Script 5) Add job to Build View for monitoring Common Job Creation steps 27
  16. “Seed Job” The seed job is a Jenkins job which

    runs a DSL scripts, and then generates a new job. 31 https://tech.gogoair.com/jenkins-jobs-as-code-with-groovy-dsl-c8143837593a
  17. v Name v Description v Schedule (CRON) v Link to

    pipeline v Environment variables v .. We created builder for generic Job 32
  18. v Developers/QAs create Seeds scripts for specific Job(s) v Store

    in GIT v One Master Seed job runs in Jenkins v executes all Seeds scripts at once Seed scripts in GIT 35
  19. 1) Listens for changes in Jobs definitions GIT repo 2)

    Launches seed scripts master-seed job Seed scripts Script with Job DSL to create jobs and views JSON data Extracted data to reuse across jobs (eg. test suite name) Pipeline scripts Scripts in pipeline DSL to use in jobs jobs jobs jobs views views views Jenkins Job definitions repository 1 2 3 4 5 Master seed job 37
  20. vRun Tests using provided parameters vMaven command (example) vTest class

    vTest suite vDevice type v... Handling similar jobs 39 mvn –Dtest=BaccaratMoveChipTest -Ddevice.type=mobile –Dtable.name…
  21. 42 vUsers work with data in JSON vAdd/remove jobs vModify

    build parameters vJob generated and included into dashboard
  22. 4 3

  23. ~50 seed scripts ~50 pipeline scripts 23 JSON files Results

    in ~2000 jobs 107 views Numbers Job and pipeline management used by developers and QA’s on a daily basis 44
  24. vAutomation and reuse vMore sense of control vScales well vEasier

    to do improvements and migrations 45 Profit
  25. Jenkins has a lot opportunities to enrich your development and

    testing 46 THANK YOU https://github.com/jenkinsci/job-dsl-plugin https://jenkins.io/doc/book/pipeline/