Configure Pull Request Flow for 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.
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:
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 -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.*"
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: Scanning Builds.
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:
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
{
"executionType": "full",
"tokenFile": "./sltoken.txt",
"createPRBuildSessionId": true,
"appName": "${JOB_NAME}",
"repositoryUrl": "https://www.github.com/${JOB_NAME}",
"pullRequestNumber": "123",
"latestCommit": "${MYGH_PR_COMMIT}",
"targetBranch": "master",
"packagesIncluded": "*com.example.*",
"packagesExcluded": "",
"filesIncluded": "*.class",
"filesExcluded": "*test-classes*",
"recursive": true,
"includeResources": true,
"testStage": "Unit Tests",
"proxy": null,
"logEnabled": false,
"logDestination": "console",
"logLevel": "warn",
"sealightsJvmParams": {}
}
If
createPRBuildSessionId
is set to true, and at least one of mandatory parameters is not specified, or empty: an error message will be printed and the build will continue without Sealights integration.If both
createPRBuildSessionId
andcreateBuildSessionId
are both set totrue
- the flow will be ambiguous, so an error message will be printed and the the build will continue without Sealights integration:"Ambiguous data: createPRBuildSessionId = true and createBuildSessionId=true, cannot create build session id."
If
createPRBuildSessionId
is set to false (default value) but PR-specific parameters are provided (repositoryUrl
,pullRequestNumber
,latestCommit
,targetBranch
) they will be ignored, build will continue as a "regular" one.
Related articles
Last updated
Was this helpful?