0

In a Makefile, how can I store the output of a command as a variable?

I am trying:

vm_instance_name = foo
registry = us.gcr.io/acmeinc
image_name = bar
image_tag = $(docker images ${registry}/${image_name} | awk '{print $2}' | awk 'NR==2')

deploy:
    gcloud beta compute instances update-container $(vm_instance_name) --container-image=$(registry)/$(image_name):$(image_tag)

But that's not working. $image_tag is empty.

Justin
  • 38,686
  • 72
  • 185
  • 276
  • 2
    Is your question about first assignment (missing `shell` call or backtick syntax) or second one that's already inside recepie? – keltar Jan 31 '20 at 09:26
  • https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile – tomgalpin Jan 31 '20 at 10:29

0 Answers0