Home > Blockchain >  Google Cloud Build: Moving files
Google Cloud Build: Moving files

Time:10-26

I want to move the file index.js from the root of the project to the dist/project_name. This is the step from cloudbuild.yaml:

  - name: 'gcr.io/cloud-builders/docker'
    entrypoint: /bin/bash
    args: ['-c', 'mv', 'index.js', 'dist/project_name']

But the step is failing with the next error:

Already have image (with digest): gcr.io/cloud-builders/docker
mv: missing file operand
Try 'mv --help' for more information.

How I can fix this issue?

CodePudding user response:

Because you're using bash -c, I think you need to encapsulate the entire "script" in a string:

args: ['-c', 'mv index.js dist/project_name']

My personal preference (and it's just that), is to not embed JSON ([...]) in YAML. This makes the result in this case slightly clearer and makes it easier to embed a multiline script:

args:
- bash
- -c
- |
  mv index js dist/project_name

NOTE tools like YAMLlint will do this for you too.

  • Related