Integrating Helix Swarm with a test suite involves enabling Automated Tests in your project's configuration and providing a trigger URL. When the trigger URL is requested, Swarm expects your test suite to be executed. When the tests complete, Swarm expects either a pass callback URL or fail callback URL to be requested by your test suite.
Select the Enable check box next to Automated Tests to display the Automated Tests configuration fields:
Provide a URL that triggers your test suite execution.
Special arguments are available to inform your test suite of various details from Swarm:
{change}
{status}
{review}
{project}
{projectName}
{branch}
{branchName}
{pass}
{fail}
The {pass}
and {fail}
are composed automatically by Swarm, and include Swarm's own per-review authentication tokens.
Optionally, specify any parameters that your automated tests require that must be sent via HTTP POST in the POST Parameters field. The POST parameters can include the special arguments listed above.
You can also choose the format of the POST parameters, either GET or JSON. When GET is selected, the POST parameters are parsed into name=value pairs. When JSON is selected, any specified parameters are passed raw in the POST body.
Your Jenkins host needs to be able to communicate with the Swarm host, and vice versa. Ensure that the appropriate DNS/host configuration is in place, and that each server can reach the other via HTTP/HTTPS.
Install the p4-plugin in Jenkins:
Configure a Jenkins project:
Specify the job name so that it matches the project identifier used in the trigger URL, as defined below.
For example, the computed value of {projectName}_{branchName}
.
Or, edit the trigger URL to use the Jenkins job name you specify.
Make the build parameterized to accept these parameters (note that these are named to match up with the script that is called):
Select Perforce Software
for the Source Code Management section.
You may see Perforce in the Source Code Management section. This represents an earlier community-provided Perforce plugin that does not include support for Swarm.
Set up credentials and workspace behavior as needed.
See the Credentials and Workspaces sections of the p4-plugin documentation for details.
The client workspace configured in Jenkins must have a view that includes the paths defined for that branch in Swarm.
Configure your Swarm project to run automated tests with a URL like this:
http://jenkins_host:8080/job/{projectName}_{branchName}/review/build?status={status}&review={review}&change={change}&pass={pass}&fail={fail}
For Jenkins, the job name needs to match the job identifier in the URL. In the example above, this is the computed value of {projectName}_{branchName}
.
If you prefer a different naming scheme in Jenkins, replace {projectName}_{branchName}
in the URL above with the project name actually defined in Jenkins.
If your build script has access to the results of test execution, include a GET or POST parameter called url when calling the pass or fail URLs. Swarm uses the provided url to link reviews to the test results.
If security is enabled in Jenkins, the trigger URL needs to include credentials. Follow these steps:
Incorporate the value of the API Token into the Swarm trigger URL.
For example, if the username is swarm and the API Token value is 832a5db7e5500c1288324c1441460610, the Swarm trigger URL should be:
http://swarm:832a5db7e5500c1288324c1441460610@jenkins_host:8080/job/{projectName}_{branchName}/review/build?cause=Automated%20test%20triggered%20for%20Swarm%20project%20{projectName},%20branch%20{branchName},%20review%20{review}&status={status}&review={review}&change={change}&pass={pass}&fail={fail}