Skip to content

lj020326/pipeline-automation-lib

Repository files navigation

License

Jenkins Pipeline Automation Library

The jenkins enabled docker image used in examples here can be found on dockerhub.

The jenkins-agent enabled docker images used in examples here can be found on dockerhub.

Pipeline Development

Notes for how to develop and test pipelines using config-as-code is here.

Key Concepts

The pipeline library was developed with a focus to ease build processes which have a more or less similar project structure e.g.

  • VMware Vsphere
  • Ansible Automation
  • Openshift
  • Kubernetes
  • Pivotal PCF
  • Maven/Java
  • local Artifact Server (e.g., Sonatype Nexus or Artifactory)
  • GIT (e.g., gitlab, gitea)

The assumption is that in these environments

  • Jenkins has a dedicated user account to checkout code (or one per project)
  • the artifact server caches public artifacts and acts as a internal artifact server

So why configure maven repositories and scm credentials in every pipeline?

So the key concepts of the pipeline enable you to

  • Auto provide credentials (no worries, only Jenkins credential ids, not the credential itself) (see Credentials)
  • Auto provide maven settings (see ManagedFiles)
  • configure each job the same way (see ConfigStructure)
  • log and see the things you are interested in (see Logging) to builds.

Running this pipeline library will result in more structured and easier to maintain pipeline scripts.

Looking for an example on how a pipeline script looks like when using Pipeline? Have a look at Usage examples

Ansible role to setup docker jenkins control node

An ansible role is used to setup all docker stack instances.

The bootstrap_docker_stack ansible role used to stand up the docker stack can be found here.

The bootstrap_docker_stack ansible role contains the jenkins config-as-code (jcac) yaml definition in template form used to setup the jenkins jcac instance.

The jcac definition can be found here.

Library Setup

Have a look at the pipeline setup tutorial to configure and start using the shared pipeline library.

This a Jenkins library built to make it easier to configure build-deploy pipelines without necessarily knowing about Jenkinsfile syntax.

When using this library, your Jenkinsfile should look something like this:

#!/usr/bin/env groovy

@Library('pipeline-automation-library')

Map config = [:]

buildVmTemplate(config)

The example above loads the library, and calls the shared buildVmTemplate pipeline used to build vm templates for vmware vsphere, kvm, virtualbox, hyperv, and other possible hypervisor environments.

Jenkins Pipeline Usage

Setup pipeline automation library used by all jenkins jobs

Configure the library in jenkins as seen below. Jenkins - Configure shared Pipeline Automation Library

Pipelines Available

Some of the most often used pipelines in this library include:

  • Run Ansible Playbook
    • runAnsibleParamWrapper - used by pipelines within a defined node hierarchy (e.g., environment and tag) to collect node parameters to start the common ansible playbook job.
      See here for document explaining example setup and usage of this pipeline.
    • runAnsibleDevJob - used to develop ansible playbooks against a branch of the ansible source repo.
  • Build Vm Template
    • buildVmTemplate - pipeline used to build vm templates for vmware vsphere, kvm, virtualbox, hyperv, and other possible hypervisor environments.
      See here for document explaining example setup and usage of this pipeline.
  • Build Docker Image
  • Run Connectivity Test
    • runConnectivityTest - pipeline used run connectivity tests from the specified jenkins nodes.
      This is mainly used by jenkins admin to verify connectivity from any/all specified jenkins nodes to the specified endpoints.
      See more detailed information here for how to use.
  • Run Application Test Harness
    • runATH - pipeline used by CICD build process at the test phases (e.g., Integration/Automation/QA testing using selenium/etc).
      See more detailed information here for how to use.
  • Run App Deployment Pipeline

Build and Deploy Spring Boot apps to PCF

See the pivotal pcf section for details.

Pipeline Screen snaps

00-pipeline-library ansible-datacenter-0-toplevel ansible-datacenter-00-pipeline-library ansible-datacenter-0b-secret-file-credential ansible-datacenter-10-CICD-dev-pipelines ansible-datacenter-10-CICD-dev-pipelines2 ansible-datacenter-10-CICD-dev-pipelines3 ansible-datacenter-11-CICD-branches ansible-datacenter-12-CICD-branches-params ansible-datacenter-13-CICD-branches-console ansible-datacenter-1a-env-dev ansible-datacenter-1aa-tags ansible-datacenter-1b-jenkins-pipeline-definition-ansible-tags ansible-datacenter-2a-deploy-vm ansible-datacenter-2b-deploy-vm-params ansible-datacenter-3a-bootstrap-linux ansible-datacenter-3b-bootstrap-linux-params ansible-datacenter-3c-bootstrap-linux-console ansible-datacenter-3d-bootstrap-linux-console ansible-datacenter-4-deploy-cacerts ansible-datacenter-5-bootstrap-dockerstack packer-templates-0-toplevel packer-templates-00-pipeline-library packer-templates-1a-os-version-builds packer-templates-1a-os-versions packer-templates-1a-os packer-templates-1a-template-build-output packer-templates-1a-template-build-wrapper packer-templates-2a-run-all-builds-config packer-templates-2b-run-all-builds-output

Contact

Linkedin

About

Jenkins CICD automation library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published