Operations 4 min read

Running Jenkins Pipelines from the Command Line with Jenkinsfile Runner

This guide explains how to use Jenkinsfile Runner to execute Jenkins pipelines locally via the command line or Docker, covering prerequisite downloads, building the runner, command‑line options, a sample Jenkinsfile, and tips on plugin management for efficient testing.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Running Jenkins Pipelines from the Command Line with Jenkinsfile Runner

Jenkinsfile Runner allows you to execute Jenkins Pipeline scripts without launching a full Jenkins instance, which is useful for development or testing scenarios.

First, download and unzip a Jenkins WAR file, then clone and build the Jenkinsfile‑Runner project with Maven.

Run the tool from the command line by specifying the WAR directory, plugin directory, Jenkinsfile path, and optional parameters, for example:

wget jenkins/war-stable/2.204.2/jenkins.war
unzip jenkins.war -d /test/jenkins
git clone https://github.com/jenkinsci/jenkinsfile-runner.git
cd jenkinsfile-runner/
mvn clean package -Dmaven.test.failure.ignore=true
jenkinsfile-runner -w /test/jenkins -p $JENKINS_HOME/plugins -f Jenkinsfile -a "param1=Hello&param2=value2"

The command‑line options are:

-w: path to the extracted WAR directory

-p: path to the Jenkins plugins directory

-f: path to the Jenkinsfile to run

-a: parameters passed to the Jenkinsfile

A sample Jenkinsfile demonstrates a simple pipeline with parameters, echo statements, and a shell step:

pipeline {
    agent any
    parameters {
        string(name: 'param1', defaultValue: '', description: 'Greeting message')
        string(name: 'param2', defaultValue: '', description: '2nd parameter')
    }
    stages {
        stage('Build') {
            steps {
                echo 'Hello world!'
                echo "message: ${params.param1}"
                echo "param2: ${params.param2}"
                sh 'ls -la'
            }
        }
    }
}

Running Jenkinsfile‑Runner produces the expected output and displays the pipeline execution logs.

Alternatively, you can use the Docker image jenkins4eval/jenkinsfile-runner, mounting the Jenkinsfile as a volume:

docker run --rm -v $(pwd)/Jenkinsfile:/workspace/Jenkinsfile jenkins4eval/jenkinsfile-runner

The summary notes that reusing the existing JenkinsHome plugins speeds up testing, while reinstalling plugins for each run can reduce efficiency, especially in remote environments.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerci/cdcommand-linePipelineJenkinsJenkinsfile Runner
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.