Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Quality Gateway wait and block pipeline + Junit exporter to use in Harness CIE #32

Open
wants to merge 113 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
60cf7e0
Quality Gateway
Jul 31, 2021
a0c3e75
Sonar with Quality Gateways Check + Java binaries setting
Jul 31, 2021
62a775a
Harness CIE SonarCube Plugin with Quality Gateway
Aug 3, 2021
d14fc28
Harness CIE SonarCube Plugin with Quality Gateway
Aug 3, 2021
e08a526
Harness CIE SonarCube Plugin with Quality Gateway
Aug 3, 2021
d7ada26
key fix patch 1
Aug 23, 2021
aaa6506
key fix patch 1
Aug 23, 2021
2123a4c
key fix patch 1
Aug 24, 2021
419854e
key fix patch 1
Aug 24, 2021
eb9c951
key fix patch 1
Aug 24, 2021
15fd7e2
key fix patch 1
Aug 24, 2021
a4be299
key fix patch 1
Aug 24, 2021
bc86bf5
key fix patch 1
Aug 24, 2021
e230ca6
key fix patch 1
Aug 24, 2021
46c0d0a
key fix patch 1
Aug 24, 2021
38b0979
key fix patch 1
Aug 24, 2021
57db9c6
key fix patch 1
Aug 24, 2021
3ea36d7
key fix patch 1
Aug 24, 2021
6d7588b
key fix patch 1
Aug 24, 2021
ba88a07
Sonar command Echo - Debug
Aug 31, 2021
242aab3
Sonar command Echo - Debug
Aug 31, 2021
5b515f1
Sonar command Echo - Debug
Aug 31, 2021
e7ac793
Sonar command Echo - Debug
Aug 31, 2021
ca9cf01
Sonar command Echo - Debug
Aug 31, 2021
4d2a026
Sonar command Echo - Debug
Sep 1, 2021
fbc5769
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
28036a5
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
cb083b3
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
51d3a7c
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
dede2b6
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
b1f9248
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
c643e44
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
d19a1f0
Sonar Project Name and Key as Setting + Wait for Sonar Quality Gatewa…
Sep 2, 2021
18e45a7
Junit Exporter
Sep 15, 2021
523faae
Junit Exporter
Sep 15, 2021
48d3099
Junit Exporter
Sep 15, 2021
b7af137
Junit Exporter
Sep 15, 2021
42ef25d
Junit Exporter
Sep 15, 2021
65c9e18
Junit Exporter
Sep 15, 2021
8f9cc9d
Junit Exporter
Sep 15, 2021
74aa89b
Junit Exporter
Sep 15, 2021
7b5df5c
Junit Exporter
Sep 15, 2021
427ee0d
Junit Exporter
Sep 15, 2021
acfb613
Junit Exporter
Sep 15, 2021
dfd5fcb
Junit Exporter
diegopereiraeng Sep 15, 2021
aa9581e
Junit Exporter
Sep 15, 2021
703c453
Junit Exporter
Sep 15, 2021
3750018
Junit Exporter
Sep 15, 2021
083642b
Junit Exporter
Sep 15, 2021
a78265f
Junit Exporter
Sep 15, 2021
bde45fa
Junit Exporter
Sep 15, 2021
1000164
Sonar Junit Exporter
Sep 15, 2021
ae9a8a4
Junit Exporter
Sep 15, 2021
0b98fe7
Junit Exporter
Sep 15, 2021
5acde38
Junit Exporter
Sep 15, 2021
87453fd
Junit Exporter
Sep 16, 2021
1d4e923
Junit Exporter
Sep 16, 2021
3061eb0
Junit Exporter
Sep 16, 2021
4f1757a
Junit Exporter
Sep 16, 2021
f701d1c
Junit Exporter
Sep 16, 2021
32557b2
Junit Exporter
Sep 17, 2021
ab653ce
Junit Exporter
Sep 17, 2021
a1d8863
Junit Exporter
Sep 17, 2021
11d5add
Merge pull request #1 from diegopereiraeng/sonar-junit-report
diegopereiraeng Sep 17, 2021
8fb005e
Junit Exporter README
Sep 17, 2021
a2664f8
Junit Exporter README
Sep 17, 2021
08c6998
setting to disable the gate if sonar conditions are not met
Sep 22, 2021
1e726ad
Artifact CIE
Sep 23, 2021
9d85608
Artifact CIE
Sep 23, 2021
450d3fa
Merge pull request #2 from diegopereiraeng/quality-gateway-enabled
diegopereiraeng Sep 23, 2021
c349218
Artifact CIE
Sep 23, 2021
ab1d881
Artifact
Sep 23, 2021
a195df8
Artifact
Sep 23, 2021
edf31af
CIE Variables Export
Sep 23, 2021
4d85021
CIE Variables Export
Sep 23, 2021
40210c8
CIE Variables Export
Sep 23, 2021
46461a7
CIE Variables Export
Sep 23, 2021
31d6e88
CIE Variables Export
Sep 23, 2021
dd2b262
CIE Variables Export
Sep 23, 2021
ed0fcf0
CIE Variables Export
Sep 23, 2021
012fd21
CIE Variables Export
Sep 23, 2021
d829b94
Merge pull request #3 from diegopereiraeng/cie-variables
diegopereiraeng Sep 24, 2021
dd4dea8
Sonar Cli Timeout as Settings
Sep 24, 2021
71a3aa0
Sonar Cli Timeout as Settings
Sep 24, 2021
f1a0aba
Sonar Cli Timeout as Settings
Sep 24, 2021
7f8e2ba
Sonar Cli Timeout as Settings
Sep 26, 2021
c04940d
Sonar Cli Timeout as Settings
Sep 26, 2021
7646c48
Sonar Cli Timeout as Settings
Sep 26, 2021
7c234d1
Sonar Cli Timeout as Settings
Sep 26, 2021
4e3e021
Sonar Cli Timeout as Settings
Sep 26, 2021
447f5b4
Sonar Cli Timeout as Settings
Sep 26, 2021
464c654
Sonar Cli Timeout as Settings
Sep 26, 2021
897adb5
Sonar Cli Timeout as Settings
Sep 26, 2021
2d7d6d0
Sonar Cli Timeout as Settings
Sep 26, 2021
eedc5b5
Sonar Cli Timeout as Settings
Sep 26, 2021
21788c9
Merge pull request #4 from diegopereiraeng/sonarcli-timeout
diegopereiraeng Sep 26, 2021
39c57e4
CIE Native - more seetings to integrate to differents scm
Sep 26, 2021
39f0d52
CIE Native - more seetings to integrate to differents scm
Sep 26, 2021
6f14917
CIE Native - more seetings to integrate to differents scm
Sep 26, 2021
b7e4afa
CIE Native - more seetings to integrate to differents scm
Sep 26, 2021
1c3d87e
Merge pull request #5 from diegopereiraeng/cie-native
diegopereiraeng Sep 26, 2021
2b21776
Sonar Cache changed to .sonar - CIE
Oct 9, 2021
d4ab90a
README
Oct 19, 2021
7ab2de5
README
Oct 19, 2021
d7cc99d
README
Oct 19, 2021
0da7c7e
README
Oct 19, 2021
17df3dc
README
Oct 19, 2021
a988be4
README
Oct 19, 2021
b56ba65
CS Coverage param
Oct 19, 2021
878bfbb
CS Coverage param
Oct 19, 2021
3ca322a
CS Coverage param
Oct 19, 2021
c465f87
CS Coverage param
Oct 19, 2021
71c7722
Merge pull request #6 from diegopereiraeng/sonar-cache-cie
diegopereiraeng Oct 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
*.zip

# Test binary, build with `go test -c`
*.test
Expand Down
30 changes: 22 additions & 8 deletions DOCS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
date: 2019-02-12T10:50:00+00:00
date: 2021-09-26T13:36:00+00:00
title: SonarQube
author: aosapps
contributor: diegopereiraeng
tags: [ Sonar, SonarQube, Analysis, report ]
logo: sonarqube.svg
repo: aosapps/drone-sonar-plugin
image: aosapps/drone-sonar-plugin
originalRepo: aosapps/drone-sonar-plugin
repo: diegopereiraeng/harness-cie-sonarqube-scanner
image: diegopereiraeng/harness-cie-sonarqube-scanner:master
---

This plugin can scan your code quality and post the analysis report to your SonarQube server. SonarQube (previously called Sonar), is an open source code quality management platform.
Expand All @@ -15,7 +17,7 @@ The below pipeline configuration demonstrates simple usage:
```yaml
steps:
- name: code-analysis
image: aosapps/drone-sonar-plugin
image: diegopereiraeng/harness-cie-sonarqube-scanner:master
settings:
sonar_host:
from_secret: sonar_host
Expand All @@ -28,7 +30,7 @@ Customized parameters could be specified:
```diff
steps:
- name: code-analysis
image: aosapps/drone-sonar-plugin
image: diegopereiraeng/harness-cie-sonarqube-scanner
settings:
sonar_host:
from_secret: sonar_host
Expand All @@ -52,6 +54,15 @@ Safety first, the host and token are stored in Drone Secrets.

# Parameter Reference

* `sonar_name`: Sonar Project NAme.
* `sonar_key`: Sonar Project Key.
* `sonar_qualitygate_timeout`: Timeout in seconds for Sonar Scan.
* `artifact_file`: Timeout in seconds for Sonar Scan.
* `sonar_quality_enabled`: True to block pipeline if sonar quality gate conditions are not met.
* `branch`: Branch for analysis.
* `build_number`: Build Version.


* `ver`: Code version, Default value `DRONE_BUILD_NUMBER`.
* `timeout`: Default seconds `60`.
* `sources`: Comma-separated paths to directories containing source files.
Expand All @@ -67,14 +78,17 @@ Safety first, the host and token are stored in Drone Secrets.
* `usingProperties`: Using the `sonar-project.properties` file in root directory as sonar parameters. (Not include `sonar_host` and
`sonar_token`.) Default value `false`

# CS (C#) Parameters

* `cs_opencover_reportsPaths`: Path to OpenCover coverage report

# Notes

* projectKey: `DRONE_REPO`
* projectName: `DRONE_REPO`
* projectKey: `PLUGIN_SONAR_KEY`
* projectName: `PLUGIN_SONAR_NAME`
* You could also add a file named `sonar-project.properties` at the root of your project to specify parameters.

Code repository: [aosapps/drone-sonar-plugin](https://github.com/aosapps/drone-sonar-plugin).
Code repository: [diegopereiraeng/harness-cie-sonarqube-scanner](https://github.com/diegopereiraeng/harness-cie-sonarqube-scanner).
SonarQube Parameters: [Analysis Parameters](https://docs.sonarqube.org/display/SONAR/Analysis+Parameters)

# Test your SonarQube Server:
Expand Down
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FROM golang:1.13.4-alpine as build
RUN mkdir -p /go/src/github.com/aosapps/drone-sonar-plugin
WORKDIR /go/src/github.com/aosapps/drone-sonar-plugin
FROM golang:1.16.6-alpine as build
RUN apk add --no-cache --update git
RUN mkdir -p /go/src/github.com/diegopereiraeng/harness-cie-sonarqube-scanner
WORKDIR /go/src/github.com/diegopereiraeng/harness-cie-sonarqube-scanner
COPY *.go ./
COPY *.mod ./
COPY vendor ./vendor/
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o drone-sonar

RUN go env GOCACHE

RUN go get github.com/sirupsen/logrus
RUN go get github.com/pelletier/go-toml/cmd/tomll
RUN go get github.com/urfave/cli
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o harness-sonar

FROM openjdk:11.0.8-jre

Expand All @@ -15,7 +23,7 @@ RUN apt-get update \
&& apt-get install -y nodejs curl \
&& apt-get clean

COPY --from=build /go/src/github.com/aosapps/drone-sonar-plugin/drone-sonar /bin/
COPY --from=build /go/src/github.com/diegopereiraeng/harness-cie-sonarqube-scanner/harness-sonar /bin/
WORKDIR /bin

RUN curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${SONAR_SCANNER_CLI}.zip -so /bin/${SONAR_SCANNER_CLI}.zip
Expand All @@ -24,4 +32,4 @@ RUN unzip ${SONAR_SCANNER_CLI}.zip \

ENV PATH $PATH:/bin/${SONAR_SCANNER}/bin

ENTRYPOINT /bin/drone-sonar
ENTRYPOINT /bin/harness-sonar
56 changes: 43 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# drone-sonar-plugin
The plugin of Drone CI to integrate with SonarQube (previously called Sonar), which is an open source code quality management platform.
# Harness CIE SonarCube Plugin with Quality Gateway

The plugin of Harness CIE to integrate with SonarQube (previously called Sonar), which is an open source code quality management platform and check the report results for status OK.

<img src="https://github.com/diegopereiraeng/harness-cie-sonarqube-scanner/blob/master/Sonar-CIE.png" alt="Plugin Configuration" width="400"/>

<img src="https://github.com/diegopereiraeng/harness-cie-sonarqube-scanner/blob/master/SonarResult.png" alt="Results" width="800"/>

<img src="https://github.com/diegopereiraeng/harness-cie-sonarqube-scanner/blob/master/SonarResultConsole.png" alt="Console Results" width="800"/>

Detail tutorials: [DOCS.md](DOCS.md).

### Build process
build go binary file:
`GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o drone-sonar`
`GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o harness-sonar`

build docker image
`docker build -t aosapps/drone-sonar-plugin .`
`docker build -t diegokoala/harness-cie-sonarqube-scanner .`


### Testing the docker image:
Expand All @@ -18,17 +25,40 @@ docker run --rm \
-e PLUGIN_SOURCES=. \
-e SONAR_HOST=http://localhost:9000 \
-e SONAR_TOKEN=60878847cea1a31d817f0deee3daa7868c431433 \
aosapps/drone-sonar-plugin
-e PLUGIN_SONAR_KEY=project-sonar \
-e PLUGIN_SONAR_NAME=project-sonar \
diegokoala/harness-cie-sonarqube-scanner
```

### Pipeline example
```yaml
steps
- name: code-analysis
image: aosapps/drone-sonar-plugin
settings:
sonar_host:
from_secret: sonar_host
sonar_token:
from_secret: sonar_token
- step:
type: Plugin
name: "Check Sonar "
identifier: Check_Sonar
spec:
connectorRef: account.DockerHubDiego
image: diegokoala/harness-cie-sonarqube-scanner:master
privileged: false
settings:
sonar_host: http://34.100.11.50
sonar_token: 60878847cea1a31d817f0deee3daa7868c431433
sources: "."
binaries: "."
sonar_name: harness-cie-sonarqube-scanner
sonar_key: harness-cie-sonarqube-scanner
- step:
type: Run
name: Sonar Show Results
identifier: Sonar_Results
spec:
connectorRef: account.DockerHubDiego
image: maven:3.6.3-jdk-8
command: ls sonarResults.xml
privileged: false
reports:
type: JUnit
spec:
paths:
- sonarResults.xml
```
Binary file added Sonar-CIE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SonarResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SonarResultConsole.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading