Skip to content

Commit

Permalink
Better errors, cater for multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaduffy committed Mar 2, 2020
1 parent a7a0100 commit 0344729
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ _Currently does not support username/password authentication and presumes you ar

```yaml
- name: Sonarscanner for dotnet
uses: Secbyte/dotnet-sonarscanner@v2.1
uses: Secbyte/dotnet-sonarscanner@v2.2
with:
buildCommand: dotnet build .
testCommand: dotnet test .
projectKey: a-project-key
projectName: a-project-name
sonarOrganisation: an-org
beginArguments: /d:sonar.verbose="true" /d:sonar.cs.opencover.reportsPaths="/path/to/coverage.xml" /d:sonar.coverage.exclusions="**/*.cs"
beginArguments: |
/d:sonar.verbose="true"
/d:sonar.cs.opencover.reportsPaths="/path/to/coverage.xml"
/d:sonar.coverage.exclusions="**/*.cs"
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
44 changes: 11 additions & 33 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -l
#!/bin/bash -l

# buildCommand = $1
# testCommand = $2
Expand All @@ -11,27 +11,19 @@

set -eu

begin_cmd="/dotnet-sonarscanner begin"
end_cmd="/dotnet-sonarscanner end"
begin_cmd="/dotnet-sonarscanner begin \\
/k:\"${3//[$'\t\r\n']:?Please set the projectKey.}\" \\
/n:\"${4//[$'\t\r\n']:?Please set the projectName.}\" \\
/o:\"${6//[$'\t\r\n']:?Please set the sonarOrganisation.}\" \\
/d:sonar.login=\"${SONAR_TOKEN:?Please set the SONAR_TOKEN environment variable.}\""

if [ -n "$3" ]
then
begin_cmd="$begin_cmd /k:\"$3\""
fi

if [ -n "$4" ]
then
begin_cmd="$begin_cmd /n:\"$4\""
fi
end_cmd="/dotnet-sonarscanner end \\
/d:sonar.login=\"${SONAR_TOKEN:?Please set the SONAR_TOKEN environment variable.}\""

if [ -n "$5" ]
then
begin_cmd="$begin_cmd /d:sonar.host.url=\"$5\""
fi

if [ -n "$6" ]
then
begin_cmd="$begin_cmd /o:\"$6\""
begin_cmd="$begin_cmd /d:sonar.host.url=\"${5//[$'\t\r\n']}\""
fi

if [ -n "$7" ]
Expand All @@ -44,27 +36,13 @@ then
end_cmd="$end_cmd $8"
fi

if [ -n "$9" ]
then
begin_cmd="$begin_cmd /d:sonar.coverage.exclusions=\"$9\""
fi

if [ -n "${SONAR_TOKEN}" ]
then
begin_cmd="$begin_cmd /d:sonar.login=\"${SONAR_TOKEN}\""
end_cmd="$end_cmd /d:sonar.login=\"${SONAR_TOKEN}\""
fi

sh -c "$begin_cmd"

if [ -n "$1" ]
then
sh -c "$1"
fi
sh -c "${1//[$'\t\r\n']:?Please set the buildCommand.}"

if [ -n "$2" ]
then
sh -c "$2"
sh -c "${2//[$'\t\r\n']}"
fi

sh -c "$end_cmd"

0 comments on commit 0344729

Please sign in to comment.