# Component File

The following steps describe the requirements to report an integration build using the Java or NodeJS build scanner.

{% hint style="warning" %}
As a **pre-requisite**, each component needs to be built, scanned, and reported to SeaLights before reporting the integration build itself.
{% endhint %}

## Create an Integration Build Session ID <a href="#create-an-integration-build-session-id" id="create-an-integration-build-session-id"></a>

Each integration build gets reported as a new build to Sealights, and therefore needs a new session ID of its own.

#### **Java Agent** <a href="#java-agent" id="java-agent"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
java -jar sl-build-scanner.jar -config -tokenfile /path/to/sltoken.txt -appname "IntegrationBuildName" -branchname "master" -buildname "1" -pi "*integration.build*" -buildsessionidfile integrationBSID.txt
```

{% endcode %}

#### **Nodejs Agent** <a href="#nodejs-agent" id="nodejs-agent"></a>

{% tabs %}
{% tab title="Unix" %}
{% code overflow="wrap" lineNumbers="true" %}

```
./node_modules/.bin/slnodejs config --tokenfile /path/to/sltoken.txt --appname "IntegrationBuildName" --branch "master" --build "1"
mv buildSessionId integrationBSID.txt
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" lineNumbers="true" %}

```
call .\node_modules.bin\slnodejs config --tokenfile \path\to\sltoken.txt --appname "IntegrationBuildName" --branch "master" --build "1"
ren buildSessionId integrationBSID.txt
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Please notice that for clarity, we have changed the default file name of the Build Session ID to `integrationBSID.txt` (instead of default `buildSessionId.txt` in Java or `buildSessionId` in slnodejs)
{% endhint %}

## Create a Components JSON File <a href="#create-a-components-json-file" id="create-a-components-json-file"></a>

Create a dependencies file using one of the formats available below. You can name this file `sl-integration-components.json` for example.

{% tabs %}
{% tab title="Using app/branch/build format for every component" %}
{% code overflow="wrap" lineNumbers="true" %}

```json
[
	{
		"appName": "sl-sample-backend",
		"branch": "master",
		"build": "1.0.1_233"
	},
	{
		"appName": "sl-sample-frontend",
		"branch": "master",
		"build": "1.2.2_44"
	}
]
```

{% endcode %}
{% endtab %}

{% tab title="Using buildSessionId format for every component" %}
{% code overflow="wrap" lineNumbers="true" %}

```json
[
	{
		"buildSessionId": "123456789"
	},
	{
		"buildSessionId": "abcdefghi"
	}
]
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
The components listed in the dependencies file must be referring to builds already reported to Sealights (including the Build Scan step) using exact same appName/branchName/buildName parameters reported.
{% endhint %}

#### Adding comments to the JSON file with components' BSID only <a href="#adding-comments-to-the-json-file-with-components-bsid-only" id="adding-comments-to-the-json-file-with-components-bsid-only"></a>

The JSON file format does not currently support comments.\
In order to assist CI job troubleshooting, when reporting a large number of components using the BSID only method, an arbitrary field can be added which serves as a component name comment e.g.

{% code overflow="wrap" lineNumbers="true" %}

```json
[
	{
		"component_name": "sample-frontend",
		"buildSessionId": "123456789"
	},
	{
		"component_name": "sample-backend",
		"buildSessionId": "abcdefghi"
	}
]
```

{% endcode %}

{% hint style="info" %}
Note that the **keywords "appName", "branch" and "build" are reserved** and cannot be used as the additional field name.
{% endhint %}

## Report the Integration Build to the Dashboard via the Build Scanner <a href="#report-the-integration-build-to-the-dashboard-via-the-build-scanner" id="report-the-integration-build-to-the-dashboard-via-the-build-scanner"></a>

Run the build scanner referencing the dependencies file created in the previous step and that we have named `sl-integration-components.json`

#### **Java Agent** <a href="#java-agent.1" id="java-agent.1"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
java -jar sl-build-scanner.jar -scan -tokenfile sltoken.txt -buildsessionidfile integrationBSID.txt -componentfile sl-integration-components.json
```

{% endcode %}

#### **Nodejs Agent** <a href="#nodejs-agent.1" id="nodejs-agent.1"></a>

{% tabs %}
{% tab title="Unix" %}
{% code overflow="wrap" lineNumbers="true" %}

```
./node_modules/.bin/slnodejs scan --tokenfile sltoken.txt --buildsessionidfile integrationBSID.txt --dependenciesFile sl-integration-components.json
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" lineNumbers="true" %}

```
call .\node_modules\.bin\slnodejs scan --tokenfile sltoken.txt --buildsessionidfile integrationBSID.txt --dependenciesFile sl-integration-components.json
```

{% endcode %}
{% endtab %}
{% endtabs %}

Once this has run, all components listed in the dependencies file will be added to the newly created integration build.

{% hint style="info" %}
Once the integration build has been created, it is possible to run cross-component integration tests, referencing the same session ID created in step #1.
{% endhint %}
