# Gitlab CI Integration
This article will guide you on how you may integrate vREST NG with Gitlab Pipelines via the vrest-ng-cli
module.
# Download configuration file
Please download the below file and rename it as .gitlab-ci.yml
. And add this file in the root directory of your source code repository.
If you are using NodeJS based project:
If you are using other than NodeJS based project:
Download Gitlab CI File (via direct download) (opens new window)
# Explanation
The process contains the following major steps in order to integrate the vrest-ng-cli
module. The steps are written on the basis of the Alpine Linux machine.
Download and install vREST NG CLI binary:
First, download and install the vREST NG CLI module.
Via NPM way
... # [Use this step] To define the vrest-ng-cli version to be downloaded variables: vrest_version: '2.0.0' #vrest-ng-cli version to be downloaded test: stage: test script: ... # download the vrest-ng-cli npm module - npm install -g vrest-ng-cli@$vrest_version ... ...
Via Direct Download way
... # [Use this step] To define the vrest-ng-cli version to be downloaded variables: vrest_version: '2.0.0' #vrest-ng-cli version to be downloaded vrest_uversion: '2_0_0' #underscore variant of vrest-ng-cli version npm_config_cache: '$CI_PROJECT_DIR/.npm' VREST_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/vrest' test: stage: test script: ... - apk update && apk add ca-certificates && update-ca-certificates && apk --no-cache add openssl wget # download the vrest-ng-cli binary if the cache doesn't exist - if [ -f $VREST_CACHE_FOLDER/vrest-ng-cli ]; then echo "vrest ng cli binary already cached."; else mkdir -p $VREST_CACHE_FOLDER && wget -O $VREST_CACHE_FOLDER/vrest-ng-cli -q https://github.com/Optimizory/vrest-ng-cli/releases/download/v$vrest_version/vrest_ng_cli_alpine_$vrest_uversion; fi # make the downloadable binary as executable - chmod u+x $VREST_CACHE_FOLDER/vrest-ng-cli ... ...
# Execute vREST NG Tests
To execute the vREST NG tests, use the following code. For detailed information on the
vrest-ng-cli
command-line options, please follow this guide link.... test: stage: test script: ... # Execute the vREST NG tests - vrest-ng-cli run --projectdir=./test/scenario-tests --logger=xunit ... ...
Note: If
vrest-ng-cli
is not in the path then provide the absolute file e.g.$VREST_CACHE_FOLDER/vrest-ng-cli
# Publish Test Results
Finally, publish the test results produced by the xunit logger of the
vrest-ng-cli
module. By default vrest-ng-cli module exports the report in thevrest_logs/logs.xml
of the current working directory. So, we can use those generated reports to publish them in Gitlab CI Pipelines.... # [Use this step] To publish test results to GitLab CI artifacts: when: always paths: - vrest_logs/logs.xml reports: junit: vrest_logs/logs.xml
# Reporting
vrest-ng-cli
module generates the following types of reports in Gitlab CI pipelines:
- Console Report
- Test Run Results