Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitlab quality pipeline #266

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions documentation/azure-devops/setup-quality-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:provider: Azure DevOps
:pipeline_type: pipeline
:trigger_sentence_azure:
:trigger_sentence: This pipeline will be configured in order to be triggered every time the test pipeline is executed successfully on a commit
:pipeline_type2: pipeline
:path_provider: azure-devops
Expand Down Expand Up @@ -65,18 +66,21 @@ NOTE: The config file for the quality {pipeline_type} is located at `/scripts/pi
[subs=attributes+]
```
./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 {extra_args_quarkus} -b develop -w

```

==== Node.js project

[subs=attributes+]
```
./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 {extra_args_quarkus} -b develop -w

```

==== Angular project

[subs=attributes+]
```
./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 {extra_args_angular} -b develop -w

```
4 changes: 4 additions & 0 deletions documentation/github/setup-quality-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:provider: GitHub
:pipeline_type: workflow
:trigger_sentence_github:
:trigger_sentence: This workflow will be configured to be executed as a job inside a CI workflow after the test (or build, if no test) job
:pipeline_type2: GitHub action
:path_provider: github
Expand Down Expand Up @@ -62,18 +63,21 @@ NOTE: The config file for the quality {pipeline_type} is located at `/scripts/pi
[subs=attributes+]
```
./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 {extra_args_quarkus} -b develop -w

```

==== Node.js project

[subs=attributes+]
```
./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 {extra_args_quarkus} -b develop -w

```

==== Angular project

[subs=attributes+]
```
./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 {extra_args_angular} -b develop -w

```
81 changes: 81 additions & 0 deletions documentation/gitlab/setup-quality-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
:provider: Gitlab
:pipeline_type: pipeline
:trigger_sentence_gitlab:
:trigger_sentence: This pipeline will be configured in order to be triggered every time the test pipeline is executed successfully on a commit
:pipeline_type2: Gitlab
:path_provider: gitlab
:extra_args_quarkus:
:extra_args_node:
:extra_args_angular:
:extra_sentence_ci: Please note that this pipeline, although manually triggerable, is designed to be executed as part of a gitlab CI pipeline.
= Setting up a Quality {pipeline_type} on {provider}

In this section we will create a quality {pipeline_type} for analyzing project code with SonarQube. {trigger_sentence}, and consumes the artifact produced by the build {pipeline_type}.

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

Then, a Pull Request (PR) will be created in order to merge the new branch into the appropriate branch (provided in `-b` flag). The PR will be automatically merged if the repository policies are met. If the merge is not possible, either the PR URL will be shown as output, or it will be opened in your web browser if using `-w` flag.

The script located at `/scripts/pipelines/{path_provider}/pipeline_generator.sh` will automatically create this new branch, create a quality {pipeline_type} 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.

{extra_sentence_ci}

== 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 https://docs.sonarqube.org/latest/user-guide/user-token/[token] (just follow the section "Generating a token").

== Creating the {pipeline_type} using provided script

=== Usage
[subs=attributes+]
```
pipeline_generator.sh \
-c <config file path> \
-l <language or framework> \
--sonar-url <sonarqube url> \
--sonar-token <sonarqube token> \
-d <project local path> \
[-b <branch>] \
[-w]
```

NOTE: The config file for the quality {pipeline_type} is located at `/scripts/pipelines/{path_provider}/templates/quality/quality-pipeline.cfg`.

=== Flags
[subs=attributes+]
```
-c, --config-file [Required] Configuration file containing {pipeline_type} definition.
-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.
-b, --target-branch Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-w Open the Pull Request on the web browser if it cannot be automatically merged. Requires -b flag.
```

=== Examples

==== Quarkus project

[subs=attributes+]
```

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -l quarkus --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/quarkus-project {extra_args_quarkus} -b develop -w
```

==== Node.js project

[subs=attributes+]
```

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -l node --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/node-project {extra_args_quarkus} -b develop -w
```

==== Angular project

[subs=attributes+]
```

./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -l angular --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/angular-project {extra_args_angular} -b develop -w
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:provider: Azure DevOps
:pipeline_type: pipeline
:trigger_sentence_azure:
:trigger_sentence: This pipeline will be configured in order to be triggered every time the test pipeline is executed successfully on a commit
:pipeline_type2: pipeline
:path_provider: azure-devops
Expand Down
16 changes: 11 additions & 5 deletions documentation/src/common_templates/setup-quality-pipeline.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif::[]
```
pipeline_generator.sh \
-c <config file path> \
-n <{pipeline_type} name> \
ifdef::trigger_sentence_azure,trigger_sentence_github[ -n <{pipeline_type} name> \]
-l <language or framework> \
--sonar-url <sonarqube url> \
--sonar-token <sonarqube token> \
Expand All @@ -41,7 +41,7 @@ NOTE: The config file for the quality {pipeline_type} is located at `/scripts/pi
[subs=attributes+]
```
-c, --config-file [Required] Configuration file containing {pipeline_type} definition.
-n, --pipeline-name [Required] Name that will be set to the {pipeline_type}.
ifdef::trigger_sentence_azure,trigger_sentence_github[-n, --pipeline-name [Required] Name that will be set to the {pipeline_type}.]
-l, --language [Required] Language or framework of the project.
--sonar-url [Required] SonarQube URL.
--sonar-token [Required] SonarQube token.
Expand All @@ -58,19 +58,25 @@ ifdef::test-pipeline[ --test-pipeline-name [Required] Test {pipeline_type

[subs=attributes+]
```
./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 {extra_args_quarkus} -b develop -w
ifdef::trigger_sentence_azure,trigger_sentence_github[./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 {extra_args_quarkus} -b develop -w]

ifdef::trigger_sentence_gitlab[./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -l quarkus --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/quarkus-project {extra_args_quarkus} -b develop -w]
```

==== Node.js project

[subs=attributes+]
```
./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 {extra_args_quarkus} -b develop -w
ifdef::trigger_sentence_azure,trigger_sentence_github[./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 {extra_args_quarkus} -b develop -w]

ifdef::trigger_sentence_gitlab[./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -l node --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/node-project {extra_args_quarkus} -b develop -w]
```

==== Angular project

[subs=attributes+]
```
./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 {extra_args_angular} -b develop -w
ifdef::trigger_sentence_azure,trigger_sentence_github[./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 {extra_args_angular} -b develop -w]

ifdef::trigger_sentence_gitlab[./pipeline_generator.sh -c ./templates/quality/quality-pipeline.cfg -l angular --sonar-url http://1.2.3.4:9000 --sonar-token 6ce6663b63fc02881c6ea4c7cBa6563b8247a04e -d C:/Users/$USERNAME/Desktop/angular-project {extra_args_angular} -b develop -w]
```
2 changes: 1 addition & 1 deletion documentation/src/github/setup-quality-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:provider: GitHub
:pipeline_type: workflow
:trigger_sentence_github:
:trigger_sentence: This workflow will be configured to be executed as a job inside a CI workflow after the test (or build, if no test) job
:pipeline_type2: GitHub action
:path_provider: github
Expand All @@ -8,4 +9,3 @@
:extra_args_angular:
:extra_sentence_ci: Please note that this workflow, although manually triggerable, is designed to be executed as part of a CI workflow, which you can create following this xref:setup-ci-pipeline.asciidoc[guide].
include::../common_templates/setup-quality-pipeline.asciidoc[]

11 changes: 11 additions & 0 deletions documentation/src/gitlab/setup-quality-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:provider: Gitlab
:pipeline_type: pipeline
:trigger_sentence_gitlab:
:trigger_sentence: This pipeline will be configured in order to be triggered every time the test pipeline is executed successfully on a commit
:pipeline_type2: Gitlab
:path_provider: gitlab
:extra_args_quarkus:
:extra_args_node:
:extra_args_angular:
:extra_sentence_ci: Please note that this pipeline, although manually triggerable, is designed to be executed as part of a gitlab CI pipeline.
include::../common_templates/setup-quality-pipeline.asciidoc[]
Loading