# Pipeline

Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.&#x20;

### Defining your Pipeline

The definition of a Jenkins Pipeline is written into a text file (called a [`Jenkinsfile`](https://www.jenkins.io/doc/book/pipeline/jenkinsfile)) which in turn is committed to a project’s source control repository.

The following sample Pipeline example is equipped with common stages of CI/CD and an additional "Meterian Scan" stage&#x20;

```
// Jenkinsfile

pipeline {
    agent any
    options {
        skipStagesAfterUnstable()
    }
    stages {
        stage('Build') {
            steps {
                // Some build steps...
            }
        }
        stage('Test') {
            steps {
                // Run tests...
            }
        }
        stage('Meterian Scan') {
            steps {
                withCredentials([string(credentialsId: 'MeterianApiToken', variable: 'METERIAN_API_TOKEN')]) {
                    sh '''
                        echo Perform Meterian vulnerability scan...
                        docker run --rm -v $(pwd):/workspace -e METERIAN_API_TOKEN=$METERIAN_API_TOKEN meterian/cli
                    '''
                }
            }
        }
        stage("Deploy") {
            steps {
                // Deployment...
            }
        }
    }
}
```

Note: the above "Meterian Scan" stage uses the [`withCredentials`](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/#withcredentials-bind-credentials-to-variables) plugin for credentials binding and requires you to set your API token within [Jenkins's credentials](https://www.jenkins.io/doc/book/using/using-credentials/) with an ID of choice.

Once your Pipeline is placed within the repository with the codebase you wish to scan, all that is left to do is configuring Jenkins for its execution.&#x20;

### Pipeline configuration in Jenkins

1\) In the Jenkins homepage, click on **New Item** on the top left dashboard

![](/files/-Mhwr_dBWsZvECgH7WLT)

2\) **Enter an item name**, from the relative wizard, specifying the name of your new Pipeline project. Then click on **Pipeline** and **OK** at the end of the page to confirm and open the Pipeline configuration page.

![](/files/-Mhwrpsm0xpP3zUgQgK4)

3\) In the Pipeline configuration page, click the **Pipeline** tab at the top of the page to scroll down to the **Pipeline** section. Here select **Pipeline script from SCM** from the **Definition** field and fill the subsequent information about your SCM of choice where your repository containing your `Jenkinsfile`is hosted

![](/files/-MhwtHUTzNc__hwMobbI)

4\) Once done configuring **Save** your work

Now when you update the designated repository, a new build is triggered, as long as the Pipeline is configured with an SCM polling trigger. Alternatively you can manually trigger it by clicking **Build Now** in your newly created Pipeline project menu.

![](/files/-MhwxVP2_ZDZ3EcUcmM3)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.meterian.io/ci-server-integrations/jenkins/pipeline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
