Triggering Executions from Jenkins

If your build process is not already using Gradle, ensure Jenkins can execute Gradle scripts.
To trigger executions in Silk Central from Jenkins:
  1. Install Gradle in Jenkins under Manage Jenkins > Global Tool Configuration.
  2. In your Jenkins project, add a build step Invoke Gradle script. Depending on where you have stored the Gradle script, you need to adapt the Build File property. Configure the step like in the following screenshot:

    1. As shown in the screenshot, you can use variables available in Jenkins, like $BUILD_NUMBER, to configure the script.
    2. If your Jenkins project is parameterized, you can pass all parameters directly to Silk Central by checking Pass all job parameters as Project properties.
  3. To show test results in Jenkins, add a post-build action Publish JUnit test result report to the Jenkins project.
  4. Specify the location, to which the script writes the files to, in the Test report XMLs field. For example sc_results/junit*.xml.

  5. Alternative: You can also use a pipeline script to configure Jenkins and to trigger executions in Silk Central. The following sample pipeline script triggers two executions in Silk Central and collects the results. The Gradle installation has the name Gradle5.4.
    node () {
      stage("Trigger Silk Central Executions") {
        def path = tool name: 'Gradle5.4', type: 'gradle'
        def scFile = new File(pwd(), "silkcentral.gradle")
        scFile.delete()
        scFile.getParentFile().mkdirs()
        writeFile([file: scFile.getAbsolutePath(), text: new URL ("http://scHost:19120/silkroot/tools/silkcentral.gradle").getText()])
        def scTriggerInfo = '-Psc_executionNodeIds=6164,6123 -Psc_host=http://scHost:19120 -Psc_token=d28930f4-9c77-4fc7-bc1d-aac4cd235d33'
        if (isUnix()) { 
          sh "${path}/bin/gradle :silkCentralLaunch -b ${scFile} " + scTriggerInfo
        } else {
          bat "${path}/bin/gradle.bat :silkCentralLaunch -b ${scFile} " + scTriggerInfo
        }
        junit 'sc_results/junit*.xml' 
      }
    }