> 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-windows-agents.md).

# CodeScan with Windows Agents

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

You will need:

1. Jenkins
2. Salesforce CLI
3. Git

### Add Environment Variables <a href="#add-environment-variables" id="add-environment-variables"></a>

* In user environment Path variable, add the **Salesforce CLI** and **Git bin directories**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2Fk5rdwHCFQ50P3SdcOPwd%2Fimage.png?alt=media&amp;token=a1ad738f-6c92-4d7e-8814-938de8acc85c" alt="" width="450"><figcaption></figcaption></figure>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FnPJ6KxoGUlHuENJJJ1dh%2Fimage.png?alt=media&amp;token=a28e91ec-a0a3-477b-99bc-bc64608ea5e4" alt="" width="395"><figcaption></figcaption></figure>

* In the System environment Path variable add the **Git\cmd**, **Git\usr\bin**, and **Salesforce CLI\bin directories**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FBOIillkw8Ki4lnoKH493%2Fimage.png?alt=media&amp;token=1db498fe-fc4f-4e5f-a30a-bd81f40fbac1" alt="" width="450"><figcaption></figcaption></figure>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FjgQo6wIUZxo26ypRMeXP%2Fimage.png?alt=media&amp;token=704f4858-73a1-4d6c-8196-302f51fe775f" alt="" width="400"><figcaption></figcaption></figure>

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

1. In [Jenkins](https://knowledgebase.autorabit.com/product-guides/codescan/codescan-integration/jenkins), create a [credential](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/injecting-secrets) containing your CodeScan token ([learn how to find this 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.
   * ***my\_organization*** should be your Organization Key ([learn how to find this here](https://knowledgebase.autorabit.com/codescan/docs/finding-your-organization-keys)).
     * The ***--server=yourserveraddress*** flag is required for self hosted instances.

{% 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 '''
echo y|sfdx plugins:install sfdx-codescan-plugin
      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-windows-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.
