Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a Jenkins Pipeline by defining its steps in a Jenkinsfile, committing that file to your project repository, and configuring a Jenkins Pipeline job to load it. For a first run, use Declarative syntax and a message-only stage; it confirms that Jenkins can load and execute the pipeline before you add project-specific build or test commands.

What you need before creating a Pipeline

  • A running Jenkins installation. Jenkins’ getting-started guide lists Jenkins 2.x or later.
  • The Pipeline plugin. It is included with the suggested plugins in the post-installation setup wizard; if Pipeline options are missing, check the installed plugins.
  • An available Jenkins agent to execute the pipeline. The agent needs the operating system and tools required by the commands you eventually add.

Jenkins Pipeline is a suite of plugins for modeling continuous-delivery workflows. You can define a pipeline in Jenkins’ classic interface or in a Jenkinsfile. Jenkins generally recommends the file-in-source-control approach so the pipeline is versioned and reviewed alongside the application. See Jenkins’ Pipeline documentation and getting-started guide.

Start with a minimal Declarative Jenkinsfile

Create a file named Jenkinsfile with this content:

pipeline {
    agent any
    stages {
        stage('Hello') {
            steps {
                echo 'Hello from Jenkins Pipeline'
            }
        }
    }
}

This example does not depend on a particular language, build system, or external command. Its structure is the smallest useful Declarative pipeline:

  • pipeline contains the Declarative definition.
  • agent any asks Jenkins to allocate an available execution agent and workspace.
  • stages groups the main units of work.
  • stage('Hello') gives one unit of work a readable name.
  • steps contains the operations Jenkins executes.
  • echo writes a message to the build’s console output.

Declarative syntax is structured and a practical starting point. Scripted Pipeline uses a limited form of Groovy and allows constructs such as loops, conditionals, and exception handling; choose it when a workflow needs that flexibility rather than adopting it by default. The official Pipeline syntax reference describes the available syntax and directives.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose where to define the Pipeline

Recommended for projects: a Jenkinsfile in source control

Place Jenkinsfile in the repository root. Jenkins can discover and manage pipeline definitions for repositories and branches this way, while changes to the build process can be reviewed and tracked with code changes. The Jenkins project describes a Jenkinsfile as typically checked into a project’s source-control repository in Creating your first Pipeline. See also Pipeline as Code.

  1. Add the minimal example above to a root-level file named Jenkinsfile.
  2. Commit and push the file to the repository branch Jenkins will build.
  3. In Jenkins, create or configure a Pipeline job to load its definition from source control. Select the appropriate repository and branch, and set the script path to Jenkinsfile if it is not already the default.
  4. Save the job and start a build. Depending on the Jenkins version and configuration, the action may be labeled Build Now or shown as a build action with different wording.
  5. Open the build’s console output and stage view. A successful first run should show the Hello stage and the message Hello from Jenkins Pipeline.

Quick experiment: define the script in the classic UI

  1. From the Jenkins Dashboard, select New Item.
  2. Enter an item name, choose a Pipeline job, and create it.
  3. In the job’s Pipeline configuration, enter the same Declarative script in the script field and save.
  4. Start a build and inspect its console output for the message.

A UI-defined script is stored with Jenkins’ job configuration under the Jenkins home directory, rather than as a file in the project repository. Screen labels can vary by Jenkins version and installed plugins. The UI route is useful for trying a small example; use a repository Jenkinsfile when you want the pipeline definition reviewed and versioned with the project.

Replace the message with project work

Add commands that are valid for the software and tools installed on the agent. For example, a project might have separate Build and Test stages, and a Deploy stage that runs only after earlier stages succeed. Jenkins’ deployment tutorial presents Build, Test, and Deploy as a basic continuous-delivery pattern—not a requirement that every pipeline deploy an application.

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'make'
            }
        }
        stage('Test') {
            steps {
                sh 'make test'
            }
        }
    }
}

Use this only if the selected agent is Unix/Linux and the project provides those commands; Jenkins does not install make or define what make test should do. On a Windows agent, use the bat step for Windows command-shell commands. A command that exits with a nonzero status normally fails its step and therefore the build, so test project commands in the same environment before relying on them in a pipeline. See Using a Jenkinsfile.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Report test results and retain build artifacts

Jenkins’ Jenkinsfile guide demonstrates the junit step for publishing test-result reports and archiveArtifacts for retaining build outputs. Add them using paths that match files your build actually creates; a pattern that matches no files may produce an error or leave the build without the expected report or artifact. Artifact archiving in Jenkins is basic retention, not a substitute for an external artifact repository.

Choose agent placement deliberately

agent any assigns the whole pipeline to any available agent. If only a particular configured node has the needed operating system or tools, use an appropriate agent label instead. For pipelines that need different environments for different stages, top-level agent none can prevent one agent being allocated for the entire pipeline, but then each stage must specify its own agent. The syntax reference documents agent placement and related directives.

Keep credentials and commands safe

Use Jenkins credentials facilities rather than putting passwords, tokens, or private keys directly in a Jenkinsfile. Avoid printing secrets in console output. Be especially careful not to interpolate user-controlled values into shell command strings: Jenkins’ Jenkinsfile guidance warns that this can permit arbitrary code execution. Restrict who can change pipeline definitions and treat values originating outside trusted code as untrusted.

Troubleshoot a first run

  • There is no Pipeline job type or Pipeline configuration section: check that the Pipeline plugin is installed and enabled. The getting-started guide lists it as a prerequisite.
  • The build cannot find the Jenkinsfile: confirm the file is committed to the branch Jenkins is building, that its spelling and capitalization are exactly Jenkinsfile, and that the job’s script path points to the file’s actual location.
  • The pipeline reports a Declarative syntax error: check braces and nesting. The top-level structure needs pipeline, an agent, stages, and a named stage containing steps.
  • The build is waiting for an executor: agent any still requires an available, online agent with an executor. Check node availability and labels; if using a label, confirm that at least one eligible agent has it.
  • A shell step fails with “command not found” or similar: the command is missing from the agent or the step does not match the operating system. Install or configure the required tool, or use bat for Windows shell commands and sh for Unix/Linux shell commands.
  • A build or test stage fails after starting: read the console output for the failing command and its exit status. A nonzero command exit fails the step; fix the project command or its environment rather than suppressing the failure without a reason.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot of a Jenkins page, you can request one with ScreenshotNeo rather than setting up a browser automation pipeline. ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. Its one-call API accepts a URL and returns a PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation for request options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://jenkins.io -o shot.webp

ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.