Current State of Nextiva Pipelines

What are we going to talk about?

  • CI/CD
  • Jenkins Pipelines
  • Using Nextiva Pipelines
  • Running Pipelines
  • Release Process
  • Hotfix Process
  • Troubleshooting
  • CI/CD Guild

CI/CD

CI/CD

Continuous Integration (CI): Is the practice of merging all developer working copies to a shared mainline several times a day.

CI/CD

Continuous Delivery: 

Is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time and, when releasing the software, doing so manually.

CI/CD

Continuous Delivery: 

Is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time and, when releasing the software, doing so manually.

CI/CD

Continuous Deployments:

Continuous delivery is the ability to deliver software that can be deployed at any time through manual releases while continuous deployment does the same but through automated deployments.

Jenkins

Jenkins is an open source automation server written in Java. Jenkins helps to automate the non-human part of the software development process, with continuous integration and facilitating technical aspects of continuous delivery.

What are Pipelines?

Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.

A continuous delivery (CD) pipeline is an automated expression of your process for getting software from version control right through to your users and customers. Every change to your software (committed in source control) goes through a complex process on its way to being released. This process involves building the software in a reliable and repeatable manner, as well as progressing the built software (called a "build") through multiple stages of testing and deployment.

What are Pipelines?

But How?

  • The definition of a Jenkins Pipeline is written into a text file called a Jenkinsfile
  • Define your stages in the Jenkinfile
  • Configure your job Jenkins

using Nextiva Pipelines

USING NEXTIVA PIPELINES

  • Create pipeline job
  • Create release-start job
  • Create release-finish job
  • Create hotfix-start job
  • Create hotfix-finish job
#!groovy
@Library('pipeline') _


jobTemplate {

    APP_NAME = 'java-app'
    DEPLOY_ON_K8S = 'false'
    BASIC_INVENTORY_PATH = 'ansible/role-based_playbooks/inventory/java-app'
    PLAYBOOK_PATH = 'ansible/role-based_playbooks/java-app.yml'
    CHANNEL_TO_NOTIFY = 'java-app'

    ansibleEnvMap = [dev       : "dev",
                     qa        : "rc",
                     production: "production"]

    projectFlow = ['language': 'java']

    healthCheckMap = [dev       : ["http://0.0.0.0:8080/health"],
                      qa        : ["http://0.0.0.0:8080/health"],
                      production: ["http://0.0.0.0:8080/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["first_user", "second_user"],
                            production: ["first_user", "second_user"]]
}

USING NEXTIVA PIPELINES

#!groovy
@Library('pipeline') _

Configures Jenkins to use a library called 'pipeline' which is also known as Nextiva Pipelines. 

USING NEXTIVA PIPELINES

jobTemplate {

    APP_NAME = 'java-app'
    DEPLOY_ON_K8S = 'false'
    BASIC_INVENTORY_PATH = 'ansible/role-based_playbooks/inventory/java-app'
    PLAYBOOK_PATH = 'ansible/role-based_playbooks/java-app.yml'
    CHANNEL_TO_NOTIFY = 'java-app'

    ansibleEnvMap = [dev       : "dev",
                     qa        : "rc",
                     production: "production"]

    projectFlow = ['language': 'java']

    healthCheckMap = [dev       : ["http://0.0.0.0:8080/health"],
                      qa        : ["http://0.0.0.0:8080/health"],
                      production: ["http://0.0.0.0:8080/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["first_user", "second_user"],
                            production: ["first_user", "second_user"]]
}

USING NEXTIVA PIPELINES

USING NEXTIVA PIPELINES

#!groovy
@Library('pipeline') _

jobTemplate {

    APP_NAME = 'java-app'
    DEPLOY_ON_K8S = 'false'
    BASIC_INVENTORY_PATH = 'ansible/role-based_playbooks/inventory/java-app'
    PLAYBOOK_PATH = 'ansible/role-based_playbooks/java-app.yml'
    CHANNEL_TO_NOTIFY = 'java-app'

    ansibleEnvMap = [dev       : "dev",
                     qa        : "rc",
                     production: "production"]

    projectFlow = ['language': 'java']

    healthCheckMap = [dev       : ["http://0.0.0.0:8080/health"],
                      qa        : ["http://0.0.0.0:8080/health"],
                      production: ["http://0.0.0.0:8080/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["first_user", "second_user"],
                            production: ["first_user", "second_user"]]
}

USING NEXTIVA PIPELINES

$ cd {{project_directory}}
$ git checkout develop
$ git pull
$ git checkout -b feature/jenkinsfile
$ touch Jenkinsfile

USING NEXTIVA PIPELINES

#!groovy
@Library('pipeline') _


jobTemplate {

    APP_NAME = 'chaley-demo-project-app'
    DEPLOY_ON_K8S = 'false'
    BASIC_INVENTORY_PATH = 'ansible/role-based_playbooks/inventory/no-op'
    PLAYBOOK_PATH = 'ansible/role-based_playbooks/no-op.yml'
    CHANNEL_TO_NOTIFY = 'java-app'

    ansibleEnvMap = [dev       : "dev",
                     qa        : "rc",
                     production: "production"]

    projectFlow = ['language': 'java']

    healthCheckMap = [dev       : ["http://10.10.10.10:8080/health"],
                      qa        : ["http://10.10.10.20:8080/health","http://10.10.10.21:8080/health"],
                      production: ["http://10.10.10.30:8080/health","http://10.10.10.31:8080/health","http://10.10.10.32:8080/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["chaley", "fLastname"],
                            production: ["chaley", "fLastname"]]
}

USING NEXTIVA PIPELINES

#!groovy
@Library('pipeline') _


jobTemplate {

    APP_NAME = 'chaley-demo-project-app'
    DEPLOY_ON_K8S = 'false'
    BASIC_INVENTORY_PATH = 'ansible/role-based_playbooks/inventory/no-op'
    PLAYBOOK_PATH = 'ansible/role-based_playbooks/no-op.yml'
    CHANNEL_TO_NOTIFY = 'java-app'

    ansibleEnvMap = [dev       : "dev",
                     qa        : "rc",
                     production: "production"]

    projectFlow = ['language': 'java'
                   'testCommands': 'mvn clean install -P jenkins && mvn checkstyle:checkstyle',
                   'postDeployCommands' : 'mvn clean install -P it' ]

    healthCheckMap = [dev       : ["http://10.10.10.10:8080/health"],
                      qa        : ["http://10.10.10.20:8080/health","http://10.10.10.21:8080/health"],
                      production: ["http://10.10.10.30:8080/health","http://10.10.10.31:8080/health","http://10.10.10.32:8080/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["chaley", "fLastname"],
                            production: ["chaley", "fLastname"]]

    MAVEN_VERSION = 'Maven 3.3.3'
    JDK_VERSION = "Java 7"

}

Common Overrides

USING NEXTIVA PIPELINES

#!groovy
@Library('pipeline') _

def BRANCH_NAME = "${env.BRANCH_NAME}"
jobTemplate {

    APP_NAME = 'chaley-demo-project-app'
    DEPLOY_ON_K8S = 'false'
    BASIC_INVENTORY_PATH = 'ansible/role-based_playbooks/inventory/no-op'
    PLAYBOOK_PATH = 'ansible/role-based_playbooks/no-op.yml'
    CHANNEL_TO_NOTIFY = 'java-app'
    
    switch (BRANCH_NAME) {
        case 'dev':
            host = "10.10.10.10"
            break
        case ~/^release\/.+$/:
            host = "10.10.10.20"
            break
        case 'master':
            host = "10.10.10.30"
            break
        default:
            break
    }

    ansibleEnvMap = [dev       : "dev",
                     qa        : "rc",
                     production: "production"]

    projectFlow = ['language': 'java'
                   'testCommands': 'mvn clean install -P jenkins && mvn checkstyle:checkstyle',
                   'postDeployCommands' : 'mvn verify -Dchaley.host=${host}' ]

    healthCheckMap = [dev       : ["http://10.10.10.10:8080/health"],
                      qa        : ["http://10.10.10.20:8080/health","http://10.10.10.21:8080/health"],
                      production: ["http://10.10.10.30:8080/health","http://10.10.10.31:8080/health","http://10.10.10.32:8080/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["chaley", "fLastname"],
                            production: ["chaley", "fLastname"]]

}

Advanced Overrides

USING NEXTIVA PIPELINES

#!groovy
@Library('pipeline') _

jobTemplate {

    APP_NAME = 'chaley-demo-project-app'
    DEPLOY_ON_K8S = true
    publishDockerImage = true
    ANSIBLE_DEPLOYMENT = false
    publishBuildArtifact = false
    CHANNEL_TO_NOTIFY = 'java-app'
    

    kubernetesClusterMap = [dev       : "dev.nextiva.io",
                            qa        : "qa.nextiva.io",
                            production: "prod.nextiva.io"]

    projectFlow = ['language': 'java'
                   'testCommands': 'mvn clean install -P jenkins && mvn checkstyle:checkstyle']

    healthCheckMap = [dev       : ["https://chaley.dev.nextiva.io/health"],
                      qa        : ["https://chaley.qa.nextiva.io/health"],
                      production: ["https://chaley.prod.nextiva.io/health"]]

    branchPermissionsMap = [dev       : ["authenticated"],
                            qa        : ["chaley", "fLastname"],
                            production: ["chaley", "fLastname"]]

}

K8S Overrides

USING NEXTIVA PIPELINES

Create Job in Jenkins

USING NEXTIVA PIPELINES

Create Job in Jenkins

USING NEXTIVA PIPELINES

USING NEXTIVA PIPELINES

Create release-start job

USING NEXTIVA PIPELINES

Create release-finish job

USING NEXTIVA PIPELINES

Create hotfix-start job

USING NEXTIVA PIPELINES

Create hotfix-finish job

Running pipelines

Running pipelines

Automatically build on commit

Running pipelines

Manually Building a Branch

Running pipelines

Manually Building a Branch

Running pipelines

Manually Building a Branch

Running pipelines

Build Status

Running pipelines

Create Pull Request 

Watch it autorun

Running pipelines

Merge PR to Develop

Watch it autorun

Release Process

  • Manually run release-start Job
  • Manually run release branch in pipeline
  • Manually run release-finish Job
  • Manually run master branch in pipeline

Release Process

Release Start Job

Release Process

Release Finish Job

Release Process

Simply run the master branch in pipelines

Production Deploy

Hotfix Process

  • Manually run hotfix-start Job
  • Manually run hotfix branch in pipeline
  • Manually run hotfix-finish Job

hotfix Process

Hotfix Start Job

hotfix Process

Hotfix Finish Job

Hotfix Process

Simply run the master branch in pipelines

Production Deploy

Troubleshooting

  • Troubleshooting document coming soon

CI/CD Guild

Contact Brent Marks to participate

Questions?

Pipelines

By Chris Haley

Pipelines

  • 850