ExpediaGroup / jenkins-spock

Unit-test Jenkins pipeline code with Spock
https://javadoc.io/doc/com.homeaway.devtools.jenkins/jenkins-spock
Apache License 2.0
186 stars 73 forks source link

getSharedLibraryVariables doesn't handle paths with spaces. #101

Open camara-tech opened 3 years ago

camara-tech commented 3 years ago

Expected Behavior

When Running the tests for the Shared Library example from a path that contains a space in it, then all the tests should pass.

Actual Behavior

Those tests for verifying "Deployer.call" all fail with

DefaultPipelineSpec > Attempts to deploy MASTER branch to PRODUCTION FAILED
    java.lang.IllegalStateException: There is no pipeline step mock for [Deployer.call].
        1. Is the name correct?
        2. Does the pipeline step have a descriptor with that name?
        3. Does that step come from a plugin? If so, is that plugin listed as a dependency in your pom.xml?
        4. If not, you may need to call explicitlyMockPipelineStep('Deployer.call') in your test's setup: block.
        at com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification.getPipelineMock(JenkinsPipelineSpecification.groovy:803)
        at DefaultPipelineSpec.Attempts to deploy MASTER branch to PRODUCTION(DefaultPipelineSpec.groovy:39)

DefaultPipelineSpec > Does NOT attempt to deploy non-MASTER branch PRODUCTION FAILED
    java.lang.IllegalStateException: There is no pipeline step mock for [Deployer.call].
        1. Is the name correct?
        2. Does the pipeline step have a descriptor with that name?
        3. Does that step come from a plugin? If so, is that plugin listed as a dependency in your pom.xml?
        4. If not, you may need to call explicitlyMockPipelineStep('Deployer.call') in your test's setup: block.
        at com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification.getPipelineMock(JenkinsPipelineSpecification.groovy:803)
        at DefaultPipelineSpec.Does NOT attempt to deploy non-MASTER branch PRODUCTION(DefaultPipelineSpec.groovy:48)

Steps to Reproduce

  1. checkout the jenkins-spock repository to a folder with a space in it (e.g. /home/user/source code/jenkins-spock)
  2. Run the tests in the shared library example

Additional Information

Based on some debugging that I did, the path that is being used in getSharedLibraryVariables contains url-encoded spaces (e.g. "%20"). The File object does not handle decoding them and returns null as expected, leading to this behavior.

awittha commented 2 years ago

Could you share line numbers of the locations where the File object's taking in a path with url encoding?