Skip to content
This repository was archived by the owner on Jan 5, 2021. It is now read-only.

Conversation

ilatypov
Copy link

@ilatypov ilatypov commented Jul 13, 2018

Pull Request template

Link to github issue (if applicable):

Changes proposed in this pull request:

  • Preserve arrays.
  • Use TEMP and JAVA_HOME.
  • Convert TEMP and JAVA_HOME to the native and POSIX format, respectively, on Cygwin, for use by the native Java and POSIX Bash, respectively.

@coveralls
Copy link

coveralls commented Jul 13, 2018

Coverage Status

Coverage decreased (-3.3%) to 23.046% when pulling 9a2da34 on ilatypov:master into 2e3cc15 on blackducksoftware:master.

@ilatypov ilatypov changed the title Preserve multi-word parameters #298. Use TEMP and JAVA_HOME. Preserve multi-word parameters. Use TEMP and JAVA_HOME. Jul 13, 2018
else
if [ -z "${DETECT_RELEASE_VERSION}" ]; then
DETECT_RELEASE_VERSION=$(curl $DETECT_CURL_OPTS 'https://test-repo.blackducksoftware.com/artifactory/api/search/latestVersion?g=com.blackducksoftware.integration&a=hub-detect&repos=bds-integrations-release')
DETECT_RELEASE_VERSION=$(curl -sSL $DETECT_CURL_OPTS 'https://test-repo.blackducksoftware.com/artifactory/api/search/latestVersion?g=com.blackducksoftware.integration&a=hub-detect&repos=bds-integrations-release')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking up the Curl man page, I think this is supposed to be -ssl not -sSL. Could you change these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each letter in the -XYZ notation is a separate option. I added the lower-case "s" to hide the progress screen and an upper-case S to show error messages such as Zscaler certificate errors.

My employer has a ticket 00085307 on specifying a space-separated value in one of the parameters,

--detect.maven.build.command="compile -s settings.xml"

The error comes from Travis with regard to submitting Sonar analysis.
The existing SonarQube server may be correct.  The SONAR_HOST_URL variable had no value.
The error said,
> You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.

I just reverted my attempts to work this around now that I logged in and authorized sonarcloud.io.
Follow Travis documentation implying that pull requests from forks are not to be inspected with SonarCloud.
https://docs.travis-ci.com/user/sonarcloud/

Attempt to classify the secure token as belonging to a certain organization so that a pull request from my fork does not get a SonarCloud inspection.
Get rid of SonarCloud as I fail to prevent its integration failure in my pull request from a fork.

https://stackoverflow.com/questions/45612758/how-do-i-get-sonarcloud-to-run-on-pull-requests-from-forks-with-travis-maven

https://travis-ci.org/blackducksoftware/hub-detect/builds/413657598

Maintainers, please re-add "sonarqube" to the script command line after my requests pulls through.
@ekerwin
Copy link
Contributor

ekerwin commented Aug 9, 2018

Changes to the shell script right now are concerning because they aren't tied to a release and are immediately put into customer's hands. This is changing soon so we'll be able to more safely introduce changes to the shell script.

This method of preserving multi-word parameters is much better than what we original did since our implementation demanded the 'rm' command be used to clean up the file we create and a customer just experienced problems with that.

In the fullness of time, we should be able to merge this PR to change the shell script as soon as we can change and test it - I'm hoping for detect 4.3.0 (sometime in the early fall of 2018).

echo "will look for snapshot: hub-detect-latest-SNAPSHOT.jar"
DETECT_SOURCE="https://test-repo.blackducksoftware.com/artifactory/bds-integrations-snapshot/com/blackducksoftware/integration/hub-detect/latest-SNAPSHOT/hub-detect-latest-SNAPSHOT.jar"
DETECT_DESTINATION="${DETECT_JAR_PATH}/hub-detect-latest-SNAPSHOT.jar"
echo "will look for snapshot: ${DETECT_SOURCE}" >&2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the edits with redirects to stderr in here are info type of messages, not errors. My opinion is that they should be sent to stdout.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for stipulating that. I dropped the ball after seeing no change in production concerning the bug itself (as opposed to following the diagnostic conventions).

rm -f $DETECT_JAR_PATH/hub-detect-java.sh
exit $RESULT
javacmd=(java ${DETECT_JAVA_OPTS} -jar "${DETECT_DESTINATION}")
type -a java || return -1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 'type -a' vs just type? It feels that using the '-a' option adds more noise than is necessary and could be misleading to someone trying to troubleshoot.
I would also move the check of java to the top after the handling of JAVA_HOME.

Copy link
Author

@ilatypov ilatypov Nov 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised I did not redirect stderr to /dev/null here. The -a option has an unfortunate double meaning in checking for all possible executable commands (not just files in PATH) and in showing them.

javacmd=(java ${DETECT_JAVA_OPTS} -jar "${DETECT_DESTINATION}")
type -a java || return -1
echo "running detect: ${javacmd[*]@Q} ${loggable_script_args[*]@Q}" >&2
"${javacmd[@]}" "${script_args[@]}" || return $?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a valid condition to have special characters within these 2 variables which require the need to print them with '@q'?

Copy link
Author

@ilatypov ilatypov Nov 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @Q operator quotes array elements, according to the new "parameter transformation" man paragraph,

https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

@DanaMaxfield
Copy link

Should the original script use “set -x”? Can’t possible check/test for everything, so using set -x can be a good catch all.
Curl can fail due to a bad domain, filename, network, etc; but the curl executable will still be successful. Can we implement the usage of getting and checking the http_code (-w "%{http_code}”). When I test this using good and bad data, the return status is always 0, but the http_code will be 200 for successful commands. My output:

$ ./testCurl.sh
Bad name status: 404 : return status: 0
Bad domain status: 404 : return status: 0
Valid file and domain status: 200 : return status: 0

@nwinkler
Copy link

nwinkler commented Feb 4, 2019

Any updates on this? When can this be integrated? (Asking since I've run into the same issue...)

@aschrab
Copy link

aschrab commented Feb 11, 2019

Should the original script use “set -x”? Can’t possible check/test for everything, so using set -x can be a good catch all.

Did you mean set -e? set -x would just show what's being done.

@JakeMathews
Copy link
Contributor

JakeMathews commented Jun 7, 2019

The scripts have moved to https://github.com/synopsys-sig/synopsys-detect-scripts and changes similar to these should be made available with the release of 5.5.0 of Synopsys-Detect (https://github.com/blackducksoftware/synopsys-detect)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants