From 1b1c59d44b68b1dc3c512866af5e39fe7fee810c Mon Sep 17 00:00:00 2001 From: stakater-user Date: Sat, 27 Jan 2024 09:53:37 +0000 Subject: [PATCH] [skip ci] Add rendered and modified Helm chart --- .../stakater-sonarqube-scan-0.0.13.yaml | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 stakater-sonarqube-scan/rendered/stakater-sonarqube-scan-0.0.13.yaml diff --git a/stakater-sonarqube-scan/rendered/stakater-sonarqube-scan-0.0.13.yaml b/stakater-sonarqube-scan/rendered/stakater-sonarqube-scan-0.0.13.yaml new file mode 100644 index 0000000..01c9f82 --- /dev/null +++ b/stakater-sonarqube-scan/rendered/stakater-sonarqube-scan-0.0.13.yaml @@ -0,0 +1,94 @@ +--- +# Source: stakater-sonarqube-scan/templates/clustertask.yaml +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: stakater-sonarqube-scan-0.0.13 +spec: + description: >- + The following task can be used to perform static analysis on the source code + provided the SonarQube server is hosted + + SonarQube is the leading tool for continuously inspecting the Code Quality and Security + of your codebases, all while empowering development teams. Analyze over 25 popular + programming languages including C#, VB.Net, JavaScript, TypeScript and C++. It detects + bugs, vulnerabilities and code smells across project branches and pull requests. + + workspaces: + - name: source + params: + - name: SONAR_HOST_URL + description: Host URL where the sonarqube server is running + default: "" + - name: SONAR_PROJECT_KEY + description: Project's unique key + default: "" + - name: SONAR_LOGIN + description: Sonar username + default: "" + - name: SONAR_PASSWORD + description: Sonar password + default: "" + - name: SONAR_CREDS_SECRET_NAME + description: Sonar credentials secret name + default: "sonar-creds" + steps: + - name: sonar-properties + image: registry.access.redhat.com/ubi8/ubi-minimal:8.9-1108.1705420507 + workingDir: $(workspaces.source.path) + env: + - name: SONAR_LOGIN + valueFrom: + secretKeyRef: + name: $(params.SONAR_CREDS_SECRET_NAME) + key: username + - name: SONAR_PASSWORD + valueFrom: + secretKeyRef: + name: $(params.SONAR_CREDS_SECRET_NAME) + key: password + script: | + #!/usr/bin/env bash + replaceValues() { + filename=$1 + thekey=$2 + newvalue=$3 + + if ! grep -R "^[#]*\s*${thekey}=.*" $filename >/dev/null; then + echo "APPENDING because '${thekey}' not found" + echo "" >>$filename + echo "$thekey=$newvalue" >>$filename + else + echo "SETTING because '${thekey}' found already" + sed -ir "s|^[#]*\s*${thekey}=.*|$thekey=$newvalue|" $filename + fi + } + + if [[ -f $(workspaces.source.path)/sonar-project.properties ]]; then + if [[ -n "$(params.SONAR_HOST_URL)" ]]; then + replaceValues $(workspaces.source.path)/sonar-project.properties sonar.host.url $(params.SONAR_HOST_URL) + fi + if [[ -n "$(params.SONAR_PROJECT_KEY)" ]]; then + replaceValues $(workspaces.source.path)/sonar-project.properties sonar.projectKey $(params.SONAR_PROJECT_KEY) + fi + + replaceValues $(workspaces.source.path)/sonar-project.properties sonar.login $SONAR_LOGIN + replaceValues $(workspaces.source.path)/sonar-project.properties sonar.password $SONAR_PASSWORD + + else + echo "No sonar-project.properties found" + exit 128 + fi + - name: sonar-scan + image: stakater/pipeline-toolbox:v0.0.36 + workingDir: $(workspaces.source.path) + command: + - /bin/bash + args: + - -c + - | + if [ -f "pom.xml" ] + then + mvn -f pom.xml clean package + fi + sonar-scanner