Page MenuHomePhabricator

Install Jenkins Pipeline Plugin for ci-staging and verify its basic functionality
Closed, ResolvedPublic

Description

Let's evaluate the Jenkins Pipeline Plugin for driving the new release pipeline. A simple verification could be to checkout the master branch of scap and have it run tox.

Event Timeline

dduvall created this task.Mar 28 2017, 11:08 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 28 2017, 11:08 PM
dduvall triaged this task as Medium priority.Mar 29 2017, 7:42 PM
dduvall moved this task from Backlog to Build PoC on the Release Pipeline board.

The Pipeline Plugin has been integrated in Jenkins 2.x :]

thcipriani closed this task as Resolved.Mar 29 2017, 11:52 PM

So the Jenkins pipeline plugin is installed and working on ci-staging-jenkins-master01.

Right now the JenkinsFile job is looking at some machine I spun up on digital ocean and downloading the scap repo from there: http://ci-staging-jenkins.wmflabs.org/ci/job/JenkinsFile

I put a simple Jenkinsfile in the scap repo on that host:

node {
    stage('Build') {
        echo 'Building...'
    }
    stage('Test') {
        git url: 'https://github.com/wikimedia/scap'
        sh 'ls'
        sh '/usr/local/bin/docker-test-build'
    }
    stage('Deploy') {
        echo 'Deploying....'
    }
}

This downloads scap from github and runs ls then /usr/local/bin/docker-test-build which I pulled and modified from a our https://integration.wikimedia.org/ci/job/differential-docker-test/

/usr/localbin/docker-test-build
#!/bin/bash
set -e

DOCKER_FILE=Dockerfile.ci
DOCKER_WORKSPACE=/srv/workspace

JOB_LOWER=$(echo "$JOB_NAME" | tr '[:upper:]' '[:lower:]')

DOCKER_BUILD_TAG="${JOB_LOWER}:${BUILD_ID}"
DOCKER_NAME="$BUILD_TAG"

[ -f "$DOCKER_FILE" ] || exit 0

onexit() {
  docker rm "${DOCKER_NAME}" || true
}

trap 'onexit $?' EXIT

docker build --file "${DOCKER_FILE}" --tag "${DOCKER_BUILD_TAG}" .
docker run --tty --name "${DOCKER_NAME}" "${DOCKER_BUILD_TAG}"

# copy all newly created files in log/ back to host workspace to be archived as artifacts
ID="$(docker ps -a --no-trunc --filter name="$DOCKER_NAME" --format "{{.ID}}" | tail -n 1)"
docker diff "$ID" | awk '$2 ~ "^'"$DOCKER_WORKSPACE"'/log/"' | while read change path; do
  if [[ "$change" == "A" ]]; then
    docker cp "$ID":"$path" "${path#"$DOCKER_WORKSPACE"/}"
  fi
done

From that simple jenkins-file I got a job that builds our scap Docker image and runs our unit tests: http://ci-staging-jenkins.wmflabs.org/ci/job/JenkinsFile/18/