Skip to content

Latest commit

 

History

History
103 lines (82 loc) · 5.49 KB

setup-quality-pipeline.asciidoc

File metadata and controls

103 lines (82 loc) · 5.49 KB

Setting up a Quality pipeline on Google Cloud

In this section we will create a quality pipeline for analyzing project code with SonarQube. This workflow will be configured to be executed after the test pipeline on any branch, and consumes the artifact produced by the build pipeline.

The creation of this pipeline will follow the project workflow, so a new branch named feature/quality-pipeline will be created and the YAML file for the pipeline will be pushed to it.

Then, the new branch will be merged into the appropriate branch (provided in -b flag).

The script located at /scripts/pipelines/gcloud/pipeline_generator.sh will automatically create this new branch, create a quality pipeline based on a YAML template appropriate for the project programming language or framework, create the Pull Request, and if it is possible, merge this new branch into the specified branch.

Prerequisites

  • This script will commit and push the corresponding YAML template into your repository, so please be sure your local repository is up-to-date (i.e you have pulled the latest changes with git pull).

  • Generate a SonarQube token (just follow the section "Generating a token").

Creating the pipeline using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <pipeline name> \
  -l <language or framework> \
  --sonar-url <sonarqube url> \
  --sonar-token <sonarqube token> \
  -d <project local path> \
  --build-pipeline-name <build pipeline name> \
  [--test-pipeline-name <test pipeline name>] \
  [-b <branch>] \
  [-m <machine type for pipeline runner>]
  [--env-vars <env vars list>]
  [--secret-vars <secret vars list>]
Note
The config file for the quality pipeline is located at /scripts/pipelines/gcloud/templates/quality/quality-pipeline.cfg.

Flags

-c, --config-file            [Required] Configuration file containing pipeline definition.
-n, --pipeline-name          [Required] Name that will be set to the pipeline.
-l, --language               [Required] Language or framework of the project.
    --sonar-url              [Required] SonarQube URL.
    --sonar-token            [Required] SonarQube token.
-d, --local-directory        [Required] Local directory of your project.
    --build-pipeline-name    [Required] Build pipeline name.
    --test-pipeline-name                Test pipeline name.
-b, --target-branch                     Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-m, --machine-type                      Machine type for pipeline runner. Accepted values: E2_HIGHCPU_8, E2_HIGHCPU_32, N1_HIGHCPU_8, N1_HIGHCPU_32.
    --env-vars                          List of environment variables to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".
    --secret-vars                       List of environment variables (saved as secrets in Secret Manager) to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".

Examples

Quarkus project

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -n quarkus-project-quality -l quarkus --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/quarkus-project --build-pipeline-name quarkus-project-build --test-pipeline-name quarkus-project-test -b develop 

Node.js project

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -n node-project-quality -l node --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/node-project --build-pipeline-name quarkus-project-build --test-pipeline-name quarkus-project-test -b develop 

Angular project

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -n angular-project-quality -l angular --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/angular-project --build-pipeline-name angular-project-build --test-pipeline-name angular-project-test -b develop 

Python project

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -n python-project-quality -l python --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/python-project --build-pipeline-name python-project-build --test-pipeline-name python-project-test -b develop 

Flutter project

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -n flutter-project-quality -l flutter --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/flutter-project --build-pipeline-name flutter-project-build --test-pipeline-name flutter-project-test -b develop