Configuring your Pull Request flow to report to SeaLights

This article explains the required steps to report your Pull request to SeaLights, compare it to the merge branch and view the results within your source control.

Note that since the results of Pull Request builds are intended to be shown as an overlay within source control using the Chrome extension, they are not displayed on the Sealights dashboard

The following steps are required to report a Pull Request to SeaLights:

Create a Build Session ID for the Pull Request

You create the Pull Request build session ID by using the SeaLights agent with the prConfig option command that requires the following parameters:

Parameter Name

Description

Parameter Name

Description

appname

The same appName reported to SeaLights for this application

targetBranch

The branch to which this PR will be merged into (already reported to SeaLights)

latestCommit

The full SHA of the last commit made to the Pull Request

pullRequestNumber

The number assigned to the Pull Request from the source control

repoUrl

The pull request URL for the PR to be scanned, up until the section before the pullRequestNumber value.

The Target branch must have builds already reported to Sealights, otherwise the prConfig command will fail.
If your development process includes pull requests merged to features branch, you may want to exclude them from the scope if Sealights analysis or enforce a build to be reported with the creation of the feature branch (via a webhook).

Sample commands

Below are examples of usage of the prConfig CLI command with the Sealights agents.

Java

java -jar sl-build-scanner.jar -prConfig -tokenfile sltoken.txt -appname "MyAppJava" -targetBranch "master" -latestCommit "$MYGH_PR_COMMIT" -pullRequestNumber "807" -repoUrl "https://www.github.com/myappjava/" -pi "*com.example.*"

slnodejs

./node_modules/.bin/slnodejs prConfig --tokenfile sltoken.txt --appname "MyAppjs" --pullRequestNumber "448" --targetBranch "develop" --latestCommit $MYGH_PR_COMMIT --repositoryUrl "https://www.github.com/myappjs/" --proxy "http://proxy2.int"

.Net/Core

SL.DotNet.exe prConfig --appName "myApp.Net" --pullRequestNumber "770" --targetBranch "develop" --latestCommit $MYGH_PR_COMMIT --repositoryUrl "https://www.github.com/myappdotnet/" --includeNamespace myNameSpace.* --buildSessionIdFile buildSessionId.txt

Python

The parameters packages included for Java and namespace for DotNet should be exactly the same as what was defined to SeaLights for the merged branch so that the compared results will be the same.

Perform a scan and run tests against the PR code

The same SeaLights flow is then configured within the PR context:

  • Using the build session ID created in the previous stage, a complete cycle is run on the PR code:

    • Build scan which includes all modules, including the code changes

    • Test executions assigned to the build are run against the code as part of the PR pipeline

See the following documentation for an example on how to configure this for Maven, using a JSON file.

Review the results within the PR view in your source control

In order to view the results in line

After performing the pull request, you will be able to view the results inline with your source control within the PR view, denoted with a red diamond:

Drilling down into the “Files Changed” tab, will allow you to see the same red diamond annotation in-line with the changed code and a toolbar summarizing Sealights analytics for this build:

 

PR Integration with Maven/Gradle plugins 

In case you have configured your “regular builds” to be reported using the JSON configuration for Sealights Maven and/or Gradle plugin, you can include dedicated fields and values to support PR configuration.

The following parameters of the configuration file provide PR integration functionality:

Parameter

Type

Notes

Parameter

Type

Notes

createPRBuildSessionId

boolean 

Mandatory. Set to true to enable PR integration (Default: false).
Cannot be true is the regular createBuildSessionId boolean is also set to true.

appName 

String

Mandatory. Name of the application as you want to see it on the SeaLights dashboard, must be exactly the same as reported from the regular pipeline builds.

repositoryUrl

String 

Mandatory. The pull request URL for the PR to be scanned, up until the section before the pullRequestNumber value.

pullRequestNumber

Number

Mandatory. The number assigned to the Pull Request from the source control.

latestCommit

String 

Mandatory. The full SHA of the last commit made to the Pull Request.

targetBranch

String 

Mandatory. The branch to which this PR will be merged into (must be already reported to SeaLights).

packagesIncluded 

String

Mandatory. Comma-separated list of packages to include in scan

packagesExcluded 

String

Optional Comma-separated list of packages to include in scan.

Sample JSON for Maven/Gradle plugin

Related articles