> For the complete documentation index, see [llms.txt](https://knowledgebase.autorabit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.autorabit.com/product-guides/codescan/codescan-integration/jenkins/codescan-with-linux-unix-agents.md).

# CodeScan with Linux/Unix Agents

To fail a Jenkins job based on the outcome of your Quality gate takes a bit of setting up but is a great way to track the health of your projects from Jenkins. This is achieved with our SFDX plugin.

### Requirements <a href="#requirements" id="requirements"></a>

You will need:

* Jenkins

### Setup Jenkins <a href="#setup-jenkins" id="setup-jenkins"></a>

1. In Jenkins, create a [**credential**](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/injecting-secrets) containing your CodeScan security token ([learn how to find security token here](https://knowledgebase.autorabit.com/codescan/docs/generate-a-security-token)).
2. Create a **new Pipeline**.
3. In the **Pipeline script** section you will need to paste in the code with the highlighted variables changed, these are:
   * Your ***credential\_name*** should be the name of the credential you created.
   * ***my\_project*** should be the project key you would like to assign to your project ([learn how to find project key here](https://knowledgebase.autorabit.com/codescan/docs/finding-your-project-key)).
   * ***my\_organization*** should be your Organization Key ([learn how to find organization key here](https://knowledgebase.autorabit.com/codescan/docs/finding-your-organization-keys)).

{% code overflow="wrap" %}

```
node {

    stage('Pull from Git') {

      git 'https://wherever.com/me/my-repo.git'

    }

    withCredentials([string(credentialsId: 'credential_name', variable: 'codescan_token')]) {
    stage('CodeScan') {
      sh '''
        export PATH="$(pwd)/.sfdx-install/bin/:$PATH"
        if [ ! -f .sfdx-install/bin/sfdx ]; then
          mkdir .sfdx-install
          wget -q https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz -O .sfdx-install/sfdx.tar.xz
          tar xJf .sfdx-install/sfdx.tar.xz -C .sfdx-install --strip-components 1
          echo y|sfdx plugins:install sfdx-codescan-plugin
sfdx plugins:update
        fi
        sfdx codescan:run --token=$codescan_token --projectkey=my_project --organization=my_organization
        exit $?
      '''       }
   } }
```

{% endcode %}

4. Run the **pipeline**. If everything is set up correctly and your Quality Gate passes, you will be able to see you pipeline pass.
5. If your Quality Gate fails, you will see the error in the CodeScan stage of the build.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://knowledgebase.autorabit.com/product-guides/codescan/codescan-integration/jenkins/codescan-with-linux-unix-agents.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
