🪲 Add dynamic projectKey input. Fixes #5

This commit is contained in:
dw1 2020-06-23 05:59:03 +07:00
parent abc24397e0
commit bb543d0f7a
2 changed files with 19 additions and 14 deletions

View File

@ -1,23 +1,27 @@
name: 'SonarQube Scan' name: "SonarQube Scan"
description: 'Scan your code with SonarQube Scanner to detect bugs, vulnerabilities and code smells in more than 25 programming languages.' description: "Scan your code with SonarQube Scanner to detect bugs, vulnerabilities and code smells in more than 25 programming languages."
author: 'Dwi Siswanto' author: "Dwi Siswanto"
branding: branding:
icon: 'check' icon: "check"
color: 'green' color: "green"
runs: runs:
using: 'docker' using: "docker"
image: 'Dockerfile' image: "Dockerfile"
inputs: inputs:
host: host:
description: 'SonarQube server URL' description: "SonarQube server URL"
required: true required: true
projectBaseDir: projectKey:
description: 'Set the sonar.projectBaseDir analysis property' description: "The project's unique key. Allowed characters are: letters, numbers, -, _, . and :, with at least one non-digit."
required: false required: false
default: '.' default: ""
projectBaseDir:
description: "Set the sonar.projectBaseDir analysis property"
required: false
default: "."
login: login:
description: 'Login or authentication token of a SonarQube user' description: "Login or authentication token of a SonarQube user"
required: true required: true
password: password:
description: 'Password that goes with the sonar.login username. This should be left blank if an authentication token is being used.' description: "Password that goes with the sonar.login username. This should be left blank if an authentication token is being used."
required: false required: false

View File

@ -11,10 +11,11 @@ if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
fi fi
[[ ! -z ${INPUT_PASSWORD} ]] && SONAR_PASSWORD="${INPUT_PASSWORD}" || SONAR_PASSWORD="" [[ ! -z ${INPUT_PASSWORD} ]] && SONAR_PASSWORD="${INPUT_PASSWORD}" || SONAR_PASSWORD=""
[[ -z ${INPUT_PROJECTKEY} ]] && SONAR_PROJECTKEY="${PWD##*/}" || SONAR_PROJECTKEY="${INPUT_PROJECTKEY}"
sonar-scanner \ sonar-scanner \
-Dsonar.host.url=${INPUT_HOST} \ -Dsonar.host.url=${INPUT_HOST} \
-Dsonar.projectKey=${PWD##*/} \ -Dsonar.projectKey=${SONAR_PROJECTKEY} \
-Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} \ -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} \
-Dsonar.login=${INPUT_LOGIN} \ -Dsonar.login=${INPUT_LOGIN} \
-Dsonar.password=${INPUT_PASSWORD} \ -Dsonar.password=${INPUT_PASSWORD} \