The following is a guide to setting up Jenkins for use with CodeScan. It assumes that:
- You have Jenkins installed.
- You have the Ant and Git plugins for Jenkins installed.
Creating a Jenkins Project for use with CodeScan
- Create a new Freestyle project.
-
Add a String parameter.
- Name it
sonar.projectVersion
- Make the default value
1
.
- Name it
-
Add another string parameter.
- Name it
salesforce.username
- Make the default value your Saleforce username eg. will@example.com
- Name it
-
Add a password parameter.
- Name it
salesforce.password
- Make the default value your Salesforce password + your Salesforce token eg. passwordtoken
- Name it
-
Add another string parameter
- Name it
salesforce.url
- Make the default value https://login.salesforce.com to pull from your production instance or https://test.salesforce.com to pull from your sandbox instance.
- Name it
-
Add another string parameter
- Name it
sonar.projectKey
- Make the default value
project1
- Name it
-
Add another string parameter
- Name it
sonar.projectName
- Make the default value whatever you like. This will be the name displayed in SonarQube™.
- Name it
-
Add another string parameter
- Name it
sonar.host.url
- Make the default value the url of your SonarQube™ instance. The default for SonarQube™ running locally would be http://localhost:9000
- Name it
-
In the build section of the configuration click Add Build Step > Invoke Ant
- In the targets section write
deletesrc download
. - In the Build File section, fill in the path to the
antbuild.xml
file in the runner folder of your CodeScan installation. eg.C:/great-tools/sonar-salesforce-plugin3.x/runner/antbuild.xml
- In the Properties section, type
user.dir=${WORKSPACE}
- Leave the Java Options blank.
- In the targets section write
-
Add another Invoke Ant step.
- In the targets section write
sonar
. - In the Build File section, fill in the path to the
antbuild.xml
file in the runner folder of your CodeScan installation. eg.C:/great-tools/sonar-salesforce-plugin3.x/runner/antbuild.xml
- In the Properties section, type
user.dir=${WORKSPACE}
- In the java options add the path to your temp directory. eg
-Djava.io.tmpdir=C:\Users\some-guy\AppData\Local\Temp\
- You can also add
-Xmx1024m
to the end of the Java Options field to assign memory.
- In the targets section write
Save the project and click Build with Parameters. The results will be available in SonarQube™