An open API service indexing awesome lists of open source software.

https://github.com/kochetkov-ma/allure-server-maven

allure-server-maven
https://github.com/kochetkov-ma/allure-server-maven

Last synced: 4 days ago
JSON representation

allure-server-maven

Awesome Lists containing this project

README

          

Maven plugin for Allure-Server
---

![GitHub release (latest by date)](https://img.shields.io/github/v/release/kochetkov-ma/allure-server-maven)

![Maven Central Version](https://img.shields.io/maven-central/v/org.brewcode.allure/allure-server-maven)

This plugin allows you to deploy Allure reports to Allure-Server.

- [allure-server](https://github.com/kochetkov-ma/allure-server)

Also, there is Gradle Plugin:

- [allure-server-gradle](https://github.com/kochetkov-ma/allure-server-gradle)

Дополненная инструкция по использованию Maven плагина для генерации отчетов Allure, включая информацию о GitLab Callback:

### Allure Maven Plugin

The `allure-server-generate` Maven plugin facilitates the generation and upload of Allure test reports to a specified server. Follow these steps to configure and use the plugin effectively:

#### Get Started

1. **Add Plugin Declaration to pom.xml:**

Include the following plugin declaration in the `` section of your `pom.xml` file:

```xml

brewcode.org.allure
allure-maven-plugin
0.1.0



allure-server-generate

site




http://your-allure-server-url
${project.build.directory}/uploaded-result-uuid.txt
${project.build.directory}/generated-report-url.txt
false
allure-results
${project.build.directory}/archives/allure-results.zip


```

2. **Configure Plugin Options:**

Customize the plugin behavior by configuring the following parameters:

- **`allureServerUrl`**: URL of the Allure server where reports will be uploaded and generated.
- **`resultUuidFile`**: File path to store the UUID of uploaded results.
- **`reportUuidFile`**: File path to store the UUID of the generated report URL.
- **`giLabCallback`**: Enable GitLab Callback for automatic comment addition to Merge Requests (ensure GitLab environment variables are set).
- **`folderName`**: Name of the folder containing Allure results.
- **`outputPath`**: Path to output the archive of Allure results.

3. **Allure PATH build**

When generating a report, it is necessary to set the `path`, which is the location where all reports will be saved. Reports with the same path will be merged into a single history. Therefore, for project X on the `Main` branch, all reports must have the same path to ensure they are combined into one history. Setting the path is a crucial step, and environment variables can be used for this purpose.

#### Environment Variables

- `PATH_PREFIX`: Prefix for the report path.
- `PATH_POSTFIX`: Postfix for the report path.
- `CI_PIPELINE_ID`: Pipeline ID. Defaults to "0" if not set.
- `CI_PIPELINE_URL`: Pipeline URL. Defaults to "localhost" if not set.
- `CI_JOB_NAME`: Job name. Defaults to "manual" if not set.
- `CI_MERGE_REQUEST_IID`: Merge request ID.
- `CI_COMMIT_REF_NAME`: Branch name. Defaults to "master" if not set.

#### Example Usage

Here is how the report path is constructed based on different environment variable settings:

- **With Merge Request ID**:
```plaintext
PATH_PREFIX: /reports
CI_MERGE_REQUEST_IID: 123
CI_JOB_NAME: build
PATH_POSTFIX: v1
```
Resulting path: `/reports/123/build/v1`

- **Without Merge Request ID**:
```plaintext
PATH_PREFIX: /reports
CI_COMMIT_REF_NAME: feature-branch
CI_JOB_NAME: build
PATH_POSTFIX: v1
```
Resulting path: `/reports/feature-branch/build/v1`

Ensure that all reports for project X that need to be merged into one history have the same path by appropriately setting the environment variables.

### Configuration Options

#### `allureServerUrl`

- **Description:** URL of the Allure server where test results will be uploaded and reports generated.
- **Example:**
```xml
http://your-allure-server-url
```

#### `resultUuidFile`

- **Description:** Path to the file where the UUID of uploaded test results will be stored.
- **Default:** `${project.build.directory}/uploaded-result-uuid.txt`
- **Example:**
```xml
${project.build.directory}/uploaded-result-uuid.txt
```

#### `reportUuidFile`

- **Description:** Path to the file where the UUID of the generated report URL will be stored.
- **Default:** `${project.build.directory}/generated-report-url.txt`
- **Example:**
```xml
${project.build.directory}/generated-report-url.txt
```

#### `giLabCallback`

- **Description:** Option to enable GitLab Callback for automatically adding comments to GitLab Merge Requests.
- **Default:** `false`
- **Example:**
```xml
true
```

#### `folderName`

- **Description:** Name of the folder where Allure test results are stored.
- **Default:** `allure-results`
- **Example:**
```xml
my-allure-results
```

#### `outputPath`

- **Description:** Path to store the archive containing Allure test results.
- **Default:** `${project.build.directory}/archives/allure-results.zip`
- **Example:**
```xml
${project.build.directory}/my-allure-reports/allure-results.zip
```

#### GitLab Callback Integration

GitLab Callback automatically adds comments to GitLab Merge Requests with links to generated Allure reports. To use this feature:

1. **Set Environment Variables in GitLab CI/CD:**

Ensure the following environment variables are set in your GitLab project's CI/CD pipeline settings:

- `CI_API_V4_URL`: URL of the GitLab API.
- `CI_PROJECT_ID`: ID of your GitLab project.
- `CI_MERGE_REQUEST_IID`: ID of the Merge Request in GitLab.
- `SERVICE_USER_API_TOKEN`: API token for accessing GitLab.

These variables are necessary for GitLab Callback to function correctly and are typically provided automatically by GitLab during pipeline execution.

2. **Configure Maven Plugin for GitLab Callback:**

Add the `giLabCallback` parameter to your Maven plugin configuration in `pom.xml` as shown in the example above. This setting enables the plugin to use GitLab environment variables for callback functionality.

### Example Configuration in pom.xml

```xml



brewcode.org.allure
allure-maven-plugin
0.1.0



allure-server-generate

site



http://your-allure-server-url
${project.build.directory}/uploaded-result-uuid.txt
${project.build.directory}/generated-report-url.txt
true
allure-results
${project.build.directory}/archives/allure-results.zip


```

This comprehensive guide provides detailed instructions on setting up and using your Maven plugin for Allure report generation, along with enabling GitLab Callback for seamless integration with GitLab CI/CD environments. Adjust configuration options and ensure environment variables are correctly set to maximize the plugin's functionality.