This blog describes how you can trigger executions from your CI server using a Gradle script. Further it describes how to get results from Silk Central and how to use them in your build process.
You can download the silkcentral.gradle file from the Tools section in Silk Central during the build process or add it to your source control system.
The script can be configured using project properties. You can either pass the properties when triggering the script or you can specify the properties in the script.
Here is a sample for launching the script from the command line:
gradle -b silkcentral.gradle :silkCentralLaunch -Psc_executionNodeIds='22431,22432,22433' -Psc_host='http://localhost:19120' -Psc_token='80827e02-cfda-4d2d-b0aa-2d5205eb6ea9'
The comma-separated list of execution tree nodes to be started eg.: 22431,22432,22433
The web-service token, generated in the Silk Central UI eg.: 80827e02-cfda-4d2d-b0aa-2d5205eb6eq9
Specify this to check out a specific branch. If no branch is specified the setting of the execution plan is used.
The build for the run. If no build is specified the setting of the execution plan is used.
Specify the tests that you want to execute. If this is not specified all assigned tests will be executed. Default value: ALL Allowed values:
The name of the build since which tests have not been executed. Specify this parameter for startOption FAILED_NOTEXECUTED_SINCE_BUILD and NOT_EXECUTED_SINCE_BUILD.
If true, the script will wait till the Silk Central execution is finished and will write results files in JUnit format. If false, the script will trigger the execution and will finish without waiting for the results. Default value: true
The start delay in seconds that can be specified if you have more than one execution plan to execute. The execution plans will be started sequentially with the specified delay between starts.
This can be helpful if you need to minimize the workload on the test environment at startup, for example when starting a virtual machine or when installing the AUT. Default value: 0
Pass parameters to Silk Central
All additional project properties, specified when launching the script, will be passed as parameters to Silk Central and are used for the execution. This enables you to parameterize the executions in Silk Central with values from the build server.
e.g.: If your build starts a test server in Docker, you can pass the URL to this server by specifying the property in the command line
If the property sc_collectResults is set to true, the script will wait till all triggered executions on Silk Central have finished and will generate JUnit.xml files out of the results. The files will be stored in the subfolder sc_results.
Trigger from Jenkins
If your build process is not already using Gradle, you have to ensure Jenkins can execute Gradle scripts.
Install Gradle in Jenkins under Manage Jenkins -> Global Tool Configuration.
Add a build step
In your project, add a build step "Invoke Gradle script".
Depending on where you have stored the script, you need to adapt the Build File property. Configure the step like in the following example:
As shown in the example, you can also use variables available in Jenkins, like $BUILD_NUMBER, to configure the script.
If your Jenkins project is parameterized, you can pass all parameters directly to Silk Central by selecting "Pass all job parameters as Project properties".
To show test results in Jenkins, add a post-build action "Publish JUnit test result report". Specify the location the script writes the files to in the Test report XMLs field.
Trigger from TeamCity
The integration with TeamCity is similar.
- Add a build step and select Runner Type: Gradle
- Gradle task: silkCentralLaunch
- Gradle build file: select the silkcentral.gradle file
- Additional gradle command line parameters (here the "-P" is needed to pass it as property):
Collect results in TeamCity
To process the test results from Silk Central, you have to add the Build Feature "XML report processing" and configure it like:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.