Page MenuHomePhabricator

Port existing `differential-docker-test` job to Jenkinsfile/Groovy
Closed, ResolvedPublic

Description

We've talked about experimenting with the Jenkins Pipeline DSL for driving the new release pipeline. Let's find out if it's viable by attempting to port the existing differential-docker-test job to use it. If successful, it may prove a good starting point for the rest of the Build PoC.

Event Timeline

Looks like there's a Docker Pipeline plugin that might provide what we need for this.

I played with this a bit today, needs some more refinement but the Dockerfile plugin made it pretty easy. The docker pipeline plugin also supports pushing to private registries which we could add as a stage in the pipeline.

Here's what I got working:

Jenkinsfile.docker
node {
    def jobName = "${JOB_NAME}:${BUILD_ID}".toLowerCase()
    def jobImg

    stage('Setup') {
        git url: 'https://github.com/wikimedia/scap'
        if (! fileExists('Dockerfile.ci')) {
            error('No Dockerfile.ci found in repo root!')
        }
    }

    stage('Build') {
        jobImg = docker.build("${jobName}", '-f Dockerfile.ci .')
    }

    stage('Test') {
        sh "docker run --rm -t ${jobName}"
    }

}

The default jobImg.run() uses docker run -d so you don't see the shell output. I suppose this mostly leaves the phab wrangling to replace differential-docker-test.

You can see the job in action here: http://ci-staging-jenkins.wmflabs.org/ci/job/Jenkinsfile.docker/

thcipriani claimed this task.

http://ci-staging-jenkins.wmflabs.org/ci/job/Jenkinsfile.docker/ does the same thing as the differential-docker-test job.

There is probably no need to port this work over to production jenkins, but it was a good initial PoC for learning Jenkinsfile format and Docker pipeline formatting.