# Jenkins Pipelines

Zirkul Jobs can be executed from Jenkins Pipelines simply by making webhook calls, however you have to make sure the API Key is protected and avoid hardcoding any secret in your pipeline scripts.

Let's start by storing the Zirkul API Key in Jenkins Credentials manager:

<figure><img src="/files/WvVr6F9tK1Zx5zaDxSht" alt=""><figcaption></figcaption></figure>

Add a new credential scoped to the project folder:

<figure><img src="/files/Eg3H33CEjOhOy9a0AJW0" alt=""><figcaption></figcaption></figure>

The kind of secret is "Secret text", in the secret section you can paste the API Key value and use the ID zirkul\_apikey (for convenience in this guide):

<figure><img src="/files/yzgD0WFRo3pUhJiKTpSf" alt=""><figcaption></figcaption></figure>

You can then use the secret within the pipeline script in the following way:

<figure><img src="/files/VWD1Z3q0KqydK9dFyF21" alt=""><figcaption></figcaption></figure>

Here's the pipeline script:

```yaml
pipeline {
    agent any

    stages {
        stage('Hello') {
            steps {
                withCredentials([string(credentialsId: 'zirkul_apikey', variable: 'zirkul_apikey')]) {
                    sh 'curl -H "X-API-KEY: $zirkul_apikey" https://app.zirkul.com/api/webhook/f3f75cca-da48-4720-be53-8c0396ca041e'
                }
            }
        }
    }
}
```

Note you may need to update the webhook id with the [URL provided by Zirkul for your Job](/devsecops/running-jobs.md#webhook-calls).

Once you run the pipeline, the console output should look like this:

<figure><img src="/files/m2kM7LFmgE8OCvrsVQLu" alt=""><figcaption></figcaption></figure>

Note:

* The API Key is protected and is not included in the logs
* The webhook call returned the message "Success"


---

# 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.zirkul.com/devsecops/jenkins-pipelines.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.
