Custom shell commands with wildcard characters in Go CI

For your build pipeline, ThoughtWork’s GO let you define tasks to invoke a shell command or script. This is extremely useful for tasks such as ssh’ing or scp’ing files to deployment servers.

For this post, we will take example of SCP.

You can setup task to scp a single file as shown in following screenshot:

For single file uploads, this work perfectly fine. But if you want to upload multiple files (for example, all zip files in the folder), you would like to specify it with shell wildcard characters like * or ?.

Unfortunately, this does not work. We get following error with above settings:

dist/*.zip: No such file or directory

The problem here is Go internally puts all parameters inside single quotes(‘) while executing command. So, even if you intended the command to run as

scp dist/*.zip

the actual command which gets executed is

scp 'dist/*.zip' ''

As the parameter is inside single quote, shell will not try to interpolate the wildcard character * in the command.

To overcome this limitation, you can use bash’s


switch. This bash switch lets you specify a string which will executed in a shell’s context.

After specifying above settings, you can achieve the intended results.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s