Quantcast
Channel: Jenkins Blog
Viewing all articles
Browse latest Browse all 1087

Continuous Delivery of Infrastructure with Jenkins

$
0
0
This is a guest post by Jenkins World speakerR Tyler Croy, infrastructure maintainer for the Jenkins project.

Jenkins World

I don’t think I have ever met a tools, infrastructure, or operations team that did not have a ton of work to do. The Jenkins project’s infrastructure "team" is no different; too much work, not enough time. In lieu of hiring more people, which isn’t always an option, I have found heavy automation and continuous delivery pipelines to be two solutions within reach of the over-worked infrastructure team.

As a big believer in the concept of "Infrastructure as Code", I have been, slowly but surely, moving the project’s infrastructure from manual tasks to code, whether implemented in our Puppet code-base,Docker containers, or even asmachine specifications withPacker. The more of our infrastructure that is code, the more we can apply continuous delivery practices to consistently and reliably build, test and deliver our infrastructure.

This approach integrates nicely withJenkins Pipeline, allowing us to also define our continuous delivery pipelines themselves as code. For example, by sanity-checking our BIND zone files:

Jenkinsfile
node('docker') {def dockerImage = 'rtyler/jenkins-infra-builder'

    checkout scm
    docker.image(dockerImage).inside {
        sh "/usr/sbin/named-checkzone jenkins-ci.org dist/profile/files/bind/jenkins-ci.org.zone"
        sh "/usr/sbin/named-checkzone jenkins.io dist/profile/files/bind/jenkins.io.zone"
    }
}

Or delivering our Docker containers automatically toDocker Hub , with a Jenkinsfile such as:

Jenkinsfile
node('docker') {
    checkout scm/* Get our abbreviated SHA-1 to uniquely identify this build */def shortCommit = sh(script: 'git rev-parse HEAD', returnStdout: true).take(6)

    stage 'Build ircbot' {
        withEnv(["JAVA_HOME=${tool 'jdk8'}", "PATH+MVN=${tool 'mvn'}/bin"]) }
            sh 'make bot'
        }
    }def whale
    stage 'Build container' {
        whale = docker.build("jenkinsciinfra/ircbot:build${shortCommit}")
    }

    stage 'Deploy container' {/* Push to Docker Hub */
        whale.push()
    }
}

Inmy talk at Jenkins World (September 14th, 3:00 - 3:45pm in Exhibit Hall A-1) I will discuss these Jenkinsfiles along with some of the strategies, patterns and code used with the Jenkins project’s open source infrastructure to get the most out of the team’s limited time.

R Tyler will bepresenting more about continous delivery of infrastructure atJenkins World in September. Register with the code JWFOSS for 20% off your full conference pass.


Viewing all articles
Browse latest Browse all 1087

Trending Articles