diff --git a/src/test/groovy/GsutilStepTests.groovy b/src/test/groovy/GsutilStepTests.groovy index cd71d0c26..96c9a565b 100644 --- a/src/test/groovy/GsutilStepTests.groovy +++ b/src/test/groovy/GsutilStepTests.groovy @@ -114,34 +114,6 @@ class GsutilStepTests extends ApmBasePipelineTest { assertJobStatusSuccess() } - @Test - void test_cache() throws Exception { - helper.registerAllowedMethod('isInstalled', [Map.class], { m -> return m.tool.equals('wget') }) - try { - script.call(command: 'cp', credentialsId: 'foo') - script.call(command: 'cp', credentialsId: 'foo') - } catch(e) { - // NOOP - } - printCallStack() - assertTrue(assertMethodCallContainsPattern('withEnv', 'PATH+GSUTIL')) - assertTrue(assertMethodCallContainsPattern('sh', 'wget -q -O')) - assertJobStatusSuccess() - } - - @Test - void test_cache_without_gsutil_installed_by_default_with_wget() throws Exception { - helper.registerAllowedMethod('isInstalled', [Map.class], { m -> return m.tool.equals('wget') }) - script.call(command: 'cp', credentialsId: 'foo') - script.call(command: 'cp', credentialsId: 'foo') - printCallStack() - assertTrue(assertMethodCallContainsPattern('withEnv', 'PATH+GSUTIL')) - assertTrue(assertMethodCallContainsPattern('sh', 'wget -q -O')) - assertTrue(assertMethodCallContainsPattern('log', 'gsutil: get the gsutilLocation from cache.')) - assertTrue(assertMethodCallContainsPattern('log', 'gsutil: set the gsutilLocation.')) - assertJobStatusSuccess() - } - @Test void test_windows() throws Exception { helper.registerAllowedMethod('isUnix', [], { false }) diff --git a/vars/gsutil.groovy b/vars/gsutil.groovy index 2296fd277..f7467507d 100644 --- a/vars/gsutil.groovy +++ b/vars/gsutil.groovy @@ -15,20 +15,10 @@ // specific language governing permissions and limitations // under the License. -import groovy.transform.Field - -@Field def gsUtilLocation = '' - def call(Map args = [:]) { def command = args.containsKey('command') ? args.command : error('gsutil: command argument is required.') def credentialsId = args.containsKey('credentialsId') ? args.credentialsId : error('gsutil: credentialsId argument is required.') - - if (gsUtilLocation?.trim()) { - log(level: 'DEBUG', text: 'gsutil: get the gsutilLocation from cache.') - } else { - log(level: 'DEBUG', text: 'gsutil: set the gsutilLocation.') - gsUtilLocation = pwd(tmp: true) - } + def gsUtilLocation = pwd(tmp: true) withEnv(["PATH+GSUTIL=${gsUtilLocation}", "PATH+GSUTIL_BIN=${gsUtilLocation}/bin"]) { if(!isInstalled(tool: 'gsutil', flag: '--version')) {