1

I need the short git commit sha (git rev-parse --short HEAD) for one of my build steps. I do not see any other way than to actually use the git builder, and then use the output in the docker build step. The below outputs what I need, and I would like to store that value in COMMIT_SHA_SHORT and use it in next build step. Is this possible somehow?

steps:
- name: 'gcr.io/cloud-builders/git'
  args: ['rev-parse', '--short', 'HEAD']
pjotr_dolphin
  • 1,207
  • 9
  • 34
  • The original problem is solved, there is a built in substitution available, SHORT_SHA, that can be used. Reference: https://cloud.google.com/container-builder/docs/configuring-builds/substitute-variable-values However, I'm still interested if it is possible to share data between the build steps. – pjotr_dolphin Apr 15 '18 at 18:38

1 Answers1

1

You can use Container Builder Custom Build [1].

A custom build step is a container image that the Container Builder worker VM pulls and runs with your source volume-mounted to /workspace. Your custom build step can execute any script or binary inside the container; as such, it can do anything a container can do.

[1] https://cloud.google.com/container-builder/docs/create-custom-build-steps

Pol Arroyo
  • 485
  • 2
  • 7