Jenkins Pipeline Tutorial: Web UI or Jenkinsfile from SCM
Updated: Oct 21
Jenkins Pipeline lets you describe a build workflow in a Jenkinsfile. You can write the same Declarative Pipeline in Jenkins’ classic UI or store it in source control. The UI is convenient for a quick test; a Jenkinsfile in Git is easier to review and version with the application.
You need a Jenkins installation with the Pipeline plugin. If you use Git, the Git plugin must also be available. Jenkins’ official Pipeline getting-started guide covers both setup paths.
Option 1: Enter the pipeline in the Jenkins UI
1. From the Jenkins Dashboard, select New Item, enter a job name such as hello-pipeline, choose Pipeline, then select OK.
2. Open the Pipeline section and set Definition to Pipeline script. Paste this small Declarative example:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Replace this with your build command'
}
}
stage('Test') {
steps {
echo 'Replace this with your test command'
}
}
}
}3. Select Save, then Build Now. Open the build number and choose Console Output to see the messages.
The script entered in the UI is stored in Jenkins’ job configuration. Use this path for a quick experiment or a simple job that does not need the pipeline definition versioned with the repository.
Option 2: Load a Jenkinsfile from Git
1. Add a file named Jenkinsfile, with no extension, to your repository. Put the same pipeline example from above in the file and commit it.
2. In Jenkins, create a Pipeline item as above. In its Pipeline section, set Definition to Pipeline script from SCM, then choose Git.
3. Enter the repository URL, choose the branch to build, and leave Script Path as Jenkinsfile if the file is at the repository root. Change Script Path if you stored the file in a subfolder.
For a private repository, select a credential already saved in Jenkins. Do not paste a personal access token into the Jenkinsfile or repository URL. Jenkins recommends handling credentials through stored credential IDs.
Save the job and run Build Now once. A later repository change triggers a build only after you configure an SCM polling trigger or the relevant source-control webhook.
When to use Multibranch Pipeline
A Pipeline script from SCM job is a straightforward fit when you want one job to build one configured branch. If you want Jenkins to discover and build branches that contain a Jenkinsfile, use Multibranch Pipeline. With the matching branch-source plugin configured, it can also discover pull requests.
Check the first run
If Jenkins reports that it cannot find the Jenkinsfile, confirm the branch and Script Path. If Git checkout fails, check the repository URL, plugin, network access, and selected credential. If the pipeline waits for an executor, confirm that an agent is online and available; agent any needs a usable executor.
The example only prints placeholder messages; it does not compile, test, or deploy an application until you replace those steps. Use the Pipeline Syntax page in your own Jenkins instance to generate plugin-specific step snippets.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.


Comments