cathive / concourse-sonarqube-resource

performs SonarQube analyses and checks quality gates https://concourse-ci.org/ https://sonarqube.org/
Apache License 2.0
46 stars 50 forks source link

Assing project status file to readonly variable #45

Closed fftorres closed 4 years ago

fftorres commented 4 years ago

With the original version I was having the following issue:

Waiting for compute engine result (sleep: 5s)...
Start parseing quality_gates...
/opt/resource/common.sh: line 234: OK: No such file or directory
/opt/resource/in: line 102: OK: No such file or directory
ERROR in /opt/resource/in : line 102 with exit code 1

I think would be safe to have a readonly variable for project status file. In my tests it fixed my issue.

headcr4sh commented 4 years ago

First of all: thanks for the PR and sorry for taking so long to finally have a look at it. I don't really understand what the change of the variable name is all about, though... or am I missing something here?

fftorres commented 4 years ago

It's not about a better variable name. Is more about some side effect about mutating the value of project_status along the script. I notice that when parse_quality_gates "${quality_gate}" "${project_status}" runs, the value of project_status becomes OK and when project_status=$(jq -r '.projectStatus.status // ""' < "${project_status}") runs, it fails because was expecting the file name. I suspect the project_status variable is being mutated in parse_quality_gates function in common.sh

headcr4sh commented 4 years ago

Mh. I see. Thanks for clarifying things for me.