How to: Run SPCAF in Jenkins Build Portal

This functionality is only available in SPCAF Quality Gate and Farm Protection. Feature Comparison.

SharePoint code analysis can be executed during a Jenkins portal build. This helps to ensure the correctness of the SharePoint code. During the Build, an overview and summary of the code quality will be reported to the build log. Additionally, the SPCAF reports can be generated and you can add build steps to easily copy these reports to a specific folder on the build server, to a network share or somewhere else that fits your requirements.

Note: This uses the same PowerShell script that Bamboo build also uses.

1. Open the Jenkins build portal and select the build that you wish to include SPCAF to.

2. Add a Windows command line build step, after any build steps that have created the finished .wps files you wish to process.

3. Copy the contents below into the build step:

md "%JENKINS_HOME%\workspace\%job_name%\wps_output"

del "%JENKINS_HOME%\workspace\%job_name%\wps_output \*.*" /Q

copy "%JENKINS_HOME%\jobs\%job_name%\builds\%BUILD_NUMBER%\buildoutput\*.*" "%JENKINS_HOME%\workspace\%job_name%\wps_output\*.*"

PowerShell -file "%JENKINS_HOME%\workspace\%job_name%\SPCAF\SPCAF.Jenkins-Bamboo.ps1" "%JENKINS_HOME%\workspace\%job_name%" SPCAF SPCAF\SPCAF_Server.lic "wps_output" "%JENKINS_HOME%\jobs\%job_name%\builds\%BUILD_NUMBER%\spcaf_reports" "HTML,CSV,XML"

4. Replace buildoutput, with the folder name (that is within the Jenkins build) that has the .wps files you wish to check using SPCAF.

In the example below, the process will take finished .wps files from the Jenkins build folder (in this case a folder called wps) and copy it to the builds workspace (in this case a folder wps_output):

md "%JENKINS_HOME%\workspace\%job_name%\wps_output"

del "%JENKINS_HOME%\workspace\%job_name%\wps_output\*.*" /Q

copy "%JENKINS_HOME%\jobs\%job_name%\builds\%BUILD_NUMBER%\wps\*.*" "%JENKINS_HOME%\workspace\%job_name%\wps_output\*.*"

PowerShell -file "%JENKINS_HOME%\workspace\%job_name%\SPCAF\SPCAF.Jenkins-Bamboo.ps1" "%JENKINS_HOME%\workspace\%job_name%" SPCAF SPCAF\SPCAF_Server.lic "wps_output" "%JENKINS_HOME%\jobs\%job_name%\builds\%BUILD_NUMBER%\spcaf_reports" "HTML,CSV,XML"

5. Save the edited build workflow.

6. Download the Then copy the folder SPCAF to the Workspace folder for build job you selected in step 1.

7. Please copy your SPCAF server license file and the SPCAF PowerShell DLL into the folder in step 6.


When the build runs the command the following steps are processed:

  • It will create a folder in the jobs workspace called wps_output
  • It will delete any contents of existing wps_output from previous build runs.
  • It will copy wps files from Jenkins build output directory (specified in step 4) to wps_output folder
  • It will then run SPCAF against the wps_output folder.
  • SPCAF will store reports (HTML,CSV, XML) to a folder called SPCAF Reports in the Jenkins build output.
  • The PowerShell script will check for any errors from SPCAF reports and fail the Jenkins build if it finds any.

Note: Download the  SPCAF Quality Gate or Farm Protection  PowerShell CmdLet from our downloads page:

Have more questions? Submit a request


Please sign in to leave a comment.