# Jenkins Integration

### Introduction <a href="#introduction" id="introduction"></a>

`Jenkins` is an open source automation server that helps you to automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.

{% hint style="info" %}
The following configuration examples show how to install & run the scanner using an API Token stored as a secret named `XYGENI_TOKEN`. See [Generate Xygeni API Token for Scanner](/xygeni-administration/platform-administration/profile.md#generate_token_for_scanner-1) or ask your Xygeni administrator to generate it.

It is recommended to store the token as a [Jenkins Credential](https://www.jenkins.io/doc/book/using/using-credentials/#using-credentials) of type "Secret text".
{% endhint %}

### Using the xygeni-scanner.zip <a href="#using_the_installation_script" id="using_the_installation_script"></a>

Replace \<PROJECT\_NAME> for the name of the project that you want to create in Xygeni.

```linenums
pipeline {
  agent any
  environment {
    XYGENI_TOKEN = credentials('XYGENI_TOKEN')
  }
  stages {
    stage('Install Xygeni scanner') {
      steps {
        sh '''
          curl -s -L "https://get.xygeni.io/latest/scanner/xygeni-release.zip" -o xygeni_scanner.zip
          unzip -qq xygeni_scanner.zip -d "${WORKSPACE}"
          rm xygeni_scanner.zip
        '''
      }
    }
    stage('Scan for issues') {
      steps {
        sh '''
          set -x # Activate debug mode to print commands inside the script
          $WORKSPACE/scanner/xygeni scan \
          -n <PROJECT_NAME> \
          --dir ${WORKSPACE}
        '''
      }
    }
  }
}
```

### Using the docker image <a href="#using_the_docker_image" id="using_the_docker_image"></a>

If it is not possible to install the scanner in the Jenkins host running the pipeline, you may run the docker image instead.

Replace \<PROJECT\_NAME> for the name of the project that you want to create in Xygeni.

```linenums
pipeline {
  agent any
  environment {
    XYGENI_TOKEN = credentials('XYGENI_TOKEN')
  }
  stages {
    stage('Scan for issues') {
      steps {
        sh '''
        docker run \
          -v ${WORKSPACE}:/app
          -v $DD_CONF:/opt/xygeni_scanner/conf \
          -t -rm \
          xygeni_scanner/xygeni scan \
          -n <PROJECT_NAME> --dir /app
        '''
      }
    }
  }
}
```

{% hint style="info" %}
See [Xygeni Scanner docker image](/xygeni-scanner-cli/xygeni-cli-overview/xygeni-cli-docker-image.md) for more details.
{% endhint %}


---

# 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.xygeni.io/xygeni-administration/platform-administration/integrations/integrate-scanner-cli-into-ci-cd-systems/jenkins-integration.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.
