SeaLights Pull Request Integration exposes Quality Risks to the developer as part of the Pull Request process, to be displayed and handled before the code is merged into the main branch.
Note that this feature is supported from GitHub Enterprise version v2.14 and newer.
SeaLights Task Runner App Configuration
To report the Pull Request data to SeaLights, the Task Runner must be installed locally on the GitHub server, or on a server with access to the GitHub Enterprise instance:
Download the Task Runner from the following link: https://sl-repo.s3.amazonaws.com/sl_task_runner/sl_task_runner-2.1.1368.zip
Prepare a configuration file to be used by the Task Runner in JSON format:
The GitHub Enterprise server properties in this configuration file should be defined within json property "
github
" as follows:
sl-taskrunner-cfg.json example: |
{ "tokenFile": "config/sltoken.txt", "github": { "url": "https://github.internal.net:443", "owner":"repo-owner", "repo":"reponame", "appId":1, "privateKeyFile":"config/github-private-key" } } |
---|
The token to be used should be an Agent token
Once the above steps have been completed, it’s time to run the task runner .jar file, specifying the configuration file created in the previous step:
java -Dsl.config.file=config/sl-taskrunner-cfg.json -jar sl_task_runner.jar
It is also possible to pass the same parameters as Java properties, like in the example below
java -Dsl.tokenFile=/path/to/sltoken.txt -Dsl.github.url=http://github.internal.net:443 -Dsl.github.owner=<owner name> -Dsl.github.repo=<repo name> -Dsl.github.appId=<app ID assigned to SL app> -Dsl.github.privateKeyFile=</path/to/private-key-file> -jar sl_task_runner.jar
SeaLights GitHub App Installation
In order to benefit of the Pull Request Analysis, you will need to create a new App on your Github Enterprise instance: https://githubenterprise.yourorg.net/settings/apps/new
This page can also be navigated to by going to your GitHub Settings > Developer Settings > Github Apps > New GitHub App
The application will not require any access to your source code It only requires:
|
Specify the app ID based on the following, after the application has been created:
The following Private Key is to be downloaded and placed in the same folder as the TaskRunner agent:
Then, navigate to Install App, and choose an account to install the SeaLights app on:
Select “All Repositories” in the following screen
Configuring the pull request job
The pull request job needs to run the SeaLights build scan and test listener for the test stages you want the analysis on.
These results will be compared to the latest build you reported to SeaLights for the branch you are merging the Pull Request to.
The difference between the pull request job and standard jobs is in how the session ID is created using Pull Request specific parameters. |
Generating a session ID
You create the Pull Request build session ID by using the SeaLights Java Build Scanner (See: Downloading the java agent files) with the prConfig option:
java -jar sl-build-scanner.jar -prConfig {-token <arg> | -tokenfile <arg>} -appname <arg> -targetBranch <arg> -latestCommit <arg> -pullRequestNumber <arg> -repoUrl <arg> [-pi <arg>] [-pe <arg>] |
Parameter | Description |
---|---|
token | Access token generated from the SeaLights server |
tokenfile | Path to file containing the access token generated from the SeaLights server |
appname | The name of the app the Pull Request is being merged to (as provided to SeaLights) |
targetBranch | The name of the branch the Pull Request is being merged to (as provided to SeaLights) |
latestCommit | The latest commit SHA of the Pull Request branch |
pullRequestNumber | The Pull Request number that is being evaluated |
repoUrl | The repository URL of the Pull Request and merged branches |
pi, packagesincluded | Comma-separated list of packages to include in scan Supports wildcards (* = any string, ? = any character). For example: 'com.example.* ,io.*.demo, com.?ello.world' |
pe, packagesexcluded | Comma-separated list of packages to exclude from scan Supports wildcards (* = any string, ? = any character). For example: 'com.example.* ,io.*.demo, com.?ello.world' |
proxy | Address of proxy to run connection through |
The packages included and excluded should be exactly the same as what was defined to SeaLights for the merged branch so that the compared results will be the same |
Pull Request parameters explanation as seen in GitHub.com
You can easily identify the relevant values to pass to the Build Scanner based on the illustration below. The screenshot is from GitHub.com, but is relevant for On Premise solutions as well.
Sample of Results on GitHub's Pull Request page
At the completion of the analysis, Sealights' App will appear as part of the "Checks" of your Pull Request. Result will appear similar to the one below: