Bug in shell script used in license management stage

Summary

License management (auto devops) stage fails with Maven and Gradle projects

Steps to reproduce

Create a Maven or Gradle project with auto devops enabled

What is the current bug behavior?

It fails with the following error: `FAILURE: Build failed with an exception.

  • What went wrong: Task 'x' not found in root project 'Foo'.`

What is the expected correct behavior?

Gradle should have run with tests disabled (build -x test, not: build x test)

Relevant logs and/or screenshots

$ /run.sh analyze .
00:16
 mesg: ttyname failed: Inappropriate ioctl for device
 switching to python 3
 pip 19.2.3 from /root/.asdf/installs/python/3.8.1/lib/python3.8/site-packages/pip (python 3.8)
 Welcome to Gradle 5.6.4!
 Here are the highlights of this release:
  - Incremental Groovy compilation
  - Groovy compile avoidance
  - Test fixtures for Java projects
  - Manage plugin versions via settings script
 For more details see https://docs.gradle.org/5.6.4/release-notes.html
 Starting a Gradle Daemon (subsequent builds will be faster)
 FAILURE: Build failed with an exception.
 * What went wrong:
 Task 'x' not found in root project 'Foo'.
 * Try:
 Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
 * Get more help at https://help.gradle.org
 BUILD FAILED in 13s
Uploading artifacts...
00:02
 WARNING: gl-license-management-report.json: no matching files 
 ERROR: No files to upload                          
 ERROR: Job failed: exit code 1

(Relevant) Results of GitLab environment info

GitLab information Version: 12.7.2-ee

Possible fixes

Bugs are in the following lines: https://gitlab.com/gitlab-org/security-products/license-management/blob/master/run.sh#L172 https://gitlab.com/gitlab-org/security-products/license-management/blob/master/run.sh#L177

Looking at: https://en.wikibooks.org/wiki/Bourne_Shell_Scripting/Variable_Expansion#Substitution_with_a_default_value

the dash is part of the syntax, not part of the resulting default value. Hence, the lines should have a dash extra. I managed to get our stages working by providing a value for that variable in my .gitlab-ci.yml stage:

license_management:
    variables:
        LM_JAVA_VERSION: 11
        GRADLE_CLI_OPTS: -x test

That way, the default is not used, and the script works as intended.