Skip to content

Commit

Permalink
Merge pull request #56 from Labout/bugfix-ignored-branch-name-file
Browse files Browse the repository at this point in the history
Fixed branch name from file being overwritten
  • Loading branch information
headcr4sh authored May 18, 2020
2 parents 90e1aa0 + 0e7486e commit 7a63d31
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions assets/out
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,25 @@ if [[ -n "${sonar_branch_name_file}" ]]; then
else
sonar_branch_name=$(cat "${sonar_branch_name_file}")
fi
fi
sonar_branch_name=$(jq -r '.params.branch_name // ""' < "${payload}")
if [[ -z "${sonar_branch_name}" ]]; then
# If the branch name or branch name file has NOT been specified, we'll check if autodetect_branch_name
# has been set to true and try to figure figure the branch out by using installed
# SCM tools.
autodetect_branch_name=$(jq -r '.params.autodetect_branch_name // "false"' < "${payload}")
if [[ "${autodetect_branch_name}" == "true" ]]; then
echo "Trying to detect branch name automatically..."
if [[ -d "${project_path}/.git" ]]; then
sonar_branch_name=$(git --git-dir="${project_path}/.git" name-rev --name-only HEAD)
else
# branch name file has NOT been specified, we'll check if branch name has been set.
sonar_branch_name=$(jq -r '.params.branch_name // ""' < "${payload}")
if [[ -z "${sonar_branch_name}" ]]; then
# If the branch name has NOT been specified, we'll check if autodetect_branch_name
# has been set to true and try to figure out the branch by using installed
# SCM tools.
autodetect_branch_name=$(jq -r '.params.autodetect_branch_name // "false"' < "${payload}")
if [[ "${autodetect_branch_name}" == "true" ]]; then
echo "Trying to detect branch name automatically..."
if [[ -d "${project_path}/.git" ]]; then
sonar_branch_name=$(git --git-dir="${project_path}/.git" name-rev --name-only HEAD)
fi
echo "Auto-detected branch name: \"${sonar_branch_name:-<nil>}\""
fi
echo "Auto-detected branch name: \"${sonar_branch_name:-<nil>}\""
fi
fi
# So... if the branch name has been either specified manually or we have been able
# to figure it out automatically using our SCM tools, we can pass sonar.branch.name
# to the sonar-scanner. Yay!!
Expand Down

0 comments on commit 7a63d31

Please sign in to comment.