Skip to content

Instantly share code, notes, and snippets.

@grahamwhaley
Created June 18, 2019 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamwhaley/57c687fbce086d6a27cd45dcf6fd1dda to your computer and use it in GitHub Desktop.
Save grahamwhaley/57c687fbce086d6a27cd45dcf6fd1dda to your computer and use it in GitHub Desktop.
jenkinsfile-runner

How to use jenkinsfile-runner

Developing pipeline jenkinsfiles can be painful. It is slightly easier if you use the jenkinsfile runner to run them locally.

Here is the script I have been using to do that for some in-dev Jenkinsfiles. Writing down as there are some subtleties here that it is going to be easy to lose and hard to re-create.

#!/bin/bash

set -x

WHERE=${HOME}/gopath/src/github.com/grahamwhaley/kata-containers/runtime/
# We are testing against a github pull request builder (ghprb) plugin triggered job build.
GHB_PULLID=1
GHB_REPO="grahamwhaley/kata-containers-runtime"
TOKEN=<YOUR GITHUB TOKEN HERE>

# Jenkins gets pretty upset and noisy about some of the env vars we are trying to pass in, so suppress it
export JAVA_OPTS="-Dhudson.model.ParametersAction.keepUndefinedParameters=true"

#docker run --rm -v ${WHERE}:/workspace jenkinsfile-runner:my-production-jenkins \
#       -a "ghprbPullId=${GHB_PULLID}" -a "ghprbGhRepository=${GHB_REPO}" -a "GITHUB_API_TOKEN=${TOKEN}" \
#       2>&1 | tee crud

docker run --rm -v ${WHERE}:/workspace \
        -e JAVA_OPTS="${JAVA_OPTS}" \
        jenkinsfile-runner:my-production-jenkins \
        -a "ghprbPullId=${GHB_PULLID}" -a "ghprbGhRepository=${GHB_REPO}" -a "GITHUB_API_TOKEN=${TOKEN}" \
        -ns \
        2>&1 | tee crud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment