makefile looks like below
BASE_JOB_IMAGE := $(shell ./fetchimageversion.sh >> image.txt)
FILE ?= image.txt
BASE_JOB_IMAGE_NAME=`cat $(FILE)`
docker build \
--pull \
--no-cache \
-t ${APPLICATION}_${TF_VER} \
--build-arg baseimage=$(BASE_JOB_IMAGE_NAME)
But I am not getting the expected output in travis logs.
docker build \
--pull \
--no-cache \
--build-arg baseimage=`cat image.txt` \
When used as BASE_JOB_IMAGE := $(shell ./fetchimageversion.sh) I do see the output of the script output but whole script execution result is set to the variable which also result in error in travis log wihth --build-arg baseimage= \ being blank
First that can't be the makefile; you have a target with no recipe. I assume that the docker
command is in a recipe. Please be sure to provide enough of an example to constitute a functional test.
Second, when you run make
what output do you see? When asking for help it's best to include the command you typed, the output you got (if it's a lot of output at least show the errors and few lines before it), and explain what you wanted. You should cut and paste this into your question: don't use screenshots and don't paraphrase/retype it where you might introduce subtle differences that might completely change the possible problem.
Third, why do you write the output to a static file but then set a variable and refer to the variable for the rest of the makefile?
Fourth, why do you use ?=
to define the filename? Do you expect to want to allow an environment variable to override the filename? That won't work if you're writing to a static filename in the previous command.
Fifth, why are you using append-to >>
when writing the file? If the file already exists this means you'll have multiple lines of content in it.
Try writing your makefile like this:
FILE = input.txt
BASE_JOB_IMAGE := $(shell ./fetchimageversion.sh >$(FILE))
BASE_JOB_IMAGE_NAME = `cat $(FILE)`
...rest of makefile...
and if that doesn't work, please provide more details as discussed in the first two paragraphs.
ETA
But, I don't know why you're going through this extra effort of writing to a file. Why not just keep the output in a variable?
BASE_JOB_IMAGE_NAME := $(shell ./fetchimageversion.sh)
...rest of makefile...