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 .wsp files you wish to process.

3. Copy the contents below into the build step:

md "%JENKINS_HOME%\workspace\%job_name%\wsp_output"

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

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

PowerShell -file "%JENKINS_HOME%\workspace\%job_name%\SPCAF\SPCAF.Jenkins-Bamboo.ps1" "%JENKINS_HOME%\workspace\%job_name%" SPCAF SPCAF\SPCAF_Server.lic "wsp_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 .wsp files you wish to check using SPCAF.

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

md "%JENKINS_HOME%\workspace\%job_name%\wsp_output"

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

copy "%JENKINS_HOME%\jobs\%job_name%\builds\%BUILD_NUMBER%\wsp\*.*" "%JENKINS_HOME%\workspace\%job_name%\wsp_output\*.*"

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

SPCAF-Jenkins-CMD_1511x307.png

5. Save the edited build workflow.

6. Download the SPCAF.Jenkins-Bamboo.zip. 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 job's workspace called wsp_output.
  • It will delete any contents of existing wsp_output from previous build runs.
  • It will copy wsp files from Jenkins build output directory (specified in step 4) to wsp_output folder
  • It will then run SPCAF against the wsp_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: https://www.spcaf.com/downloads/

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.