CodeScan with Windows Agents


You will need:

  1. Jenkins

  2. Salesforce CLI

  3. Git

Add Environment Variables

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

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

Setup Jenkins

  1. In Jenkins, create a credential containing your CodeScan token (learn how to find this here).

  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).

      • The --server=yourserveraddress flag is required for self hosted instances.

node {

    stage('Pull from Git') {

      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 $?
  1. Run the pipeline. If everything is set up correctly and your Quality Gate passes, you will be able to see you pipeline pass.

  2. If your Quality Gate fails, you will see the error in the CodeScan stage of the build.

Last updated