I'm using Google Cloud Build and in one of its steps, I'm running a Bazel build. I'm trying to use substitutions to build multiple targets in one invocation.
When:
{
"name": "gcr.io/cloud-builders/bazel",
"args": [
"build",
"$_TARGETS",
]
}
TARGETS
substitution is //foo/... //bar/...
The command that is actually running is bazel build "//foo/... //bar/..."
and that obviously results in an invalid target name error. (A single target works just fine)
The end result should be something like bazel build //foo/... //bar/...
Is there a way to "split" multiple arguments in a single sub? or make the command treat the arguments separately?
I tough to a workaround. I tested with Bazel (not build, I don't have example with, but with help, version and other simple keyword. It seams working.
With Cloud Build you are able to execute linux command, even with specific Cloud Builder. Simply specify the entrypoint
.
{
"name": "gcr.io/cloud-builders/bazel",
"entrypoint": "bash",
"args": [
"-c",
"bazel build $_TARGETS",
]
}
You should achieve what you want. If not try to update the $_TARGET
by $(echo $_TARGET)
to print the $_TARGET
(and thus, to delete the quotes if still present)