Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/test/groovy/GsutilStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
12 changes: 1 addition & 11 deletions vars/gsutil.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down