RackHD Jenkins pipeline coding convention

This provides best practice of Jenkins pipeline coding convention .




Goal:

  1. Put all Jenkins jobs under source code.
  2. Dashboard shows different jobs according to role type.
  3. Put all the nodes in a resource pool.

For example, several stacks for continuous test, smoke test

Pipeline should lock a stack for  smoke test, continuous test…

Developers should lock a stack before debug with the specified node.

 

Success Criteria:

  1. Implement functions and handy dashboard 
  2. It’s convenience to check log. (Try to avoid triggering other job)

Code Convention & Guideline

  1. Avoid exposing sensitive information with Jenkins plugin: Credentials Binding Plugin
  2. If a pipeline is reused in other pipelines, try to reuse by code instead of re-use job like before, it can be implemented with groovy method(library file) or a runnable groovy script.
  3. adding comments for auto-generated groovy part
  4. Pipeline BEST_PRACTICES


Current code structure:

Our pipeline code is under on-build-config/jobs

on-build-config/jobs/
├── build_debian
│   ├── build_debian.groovy
│   └── build_debian.sh
├── build_docker
│   ├── build_docker.groovy
│   ├── build_docker.sh
│   ├── docker_post_test.groovy
│   └── prepare_docker_post_test.sh
├── build_ova
│   ├── ansible
│   │   └── main.yml
│   ├── build_ova.groovy
│   ├── build_ova.sh
│   ├── ova_post_test.groovy
│   └── prepare_ova_post_test.sh
├── build_vagrant
│   ├── build_vagrant.groovy
│   ├── build_vagrant.sh
│   ├── vagrant_post_test.groovy
│   └── vagrant_post_test.sh
├── ContinuousTest                     
│   └── Jenkinsfile                    //Job ContinuousFunctionTest entrypoint
├── create_manifest
│   ├── create_manifest.groovy
│   └── create_manifest.sh
├── FunctionTest
│   ├── cleanup.sh
│   ├── FunctionTest.groovy
│   ├── prepare_common.sh
│   └── prepare_manifest.sh
├── MasterCI                              
│   └── MasterCI                       //Job MasterCI entrypoint
├── PackerCacheBuild             
│   └── Jenkinsfile                    //Job PACKER_CACHE_BUILD entrypoint
├── pr_gate                                
│   ├── Jenkinsfile                    //Job on-xxx entrypoint 
│   └── pr_parser.groovy
├── release
│   ├── release_debian.groovy
│   ├── release_debian.sh
│   ├── release_docker.groovy
│   ├── release_docker.sh
│   ├── release_npm.groovy
│   ├── release_vagrant.groovy
│   └── release_vagrant.sh
├── ShareMethod.groovy
├── SprintRelease                   //Job SprintRelease entrypoint
│   ├── bump_version.groovy
│   ├── check_jira.groovy
│   ├── create_tag.groovy
│   ├── create_tag.sh
│   ├── Jenkinsfile
│   └── update_manifest.sh
├── SprintTag
│   ├── create_tag.groovy
│   ├── create_tag.sh
│   └── Jenkinsfile
├── UnitTest
│   ├── PRGateUnitTest.groovy
│   ├── UnitTest.groovy
│   └── unit_test.sh
└── write_back_github
     ├── write_back_github.groovy
     └── write_back_github.sh

     

Former user (Deleted)  drafting.