0

I am trying below code in Dockerfile but I am getting error while I build the Docker image.

ENV GITHUB_RUNNER_VERSION=''
RUN $(curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]') >> ${GITHUB_RUNNER_VERSION}


RUN curl -Ls https://github.com/actions/runner/releases/download/v$GITHUB_RUNNER_VERSION/actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz | tar zx \
  && chown -R github:github /work \
  && sudo ./bin/installdependencies.sh

Error:

Step 10/20 : RUN curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]' >> ${GITHUB_RUNNER_VERSION}
 ---> Running in a827248e3eb4
/bin/sh: 1: cannot create : Directory nonexistent
The command '/bin/sh -c curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]' >> ${GITHUB_RUNNER_VERSION}' returned a non-zero code: 2
Error: exit status 2

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Irfan Pathan
  • 309
  • 1
  • 3
  • 14
  • The reason i am using curl above to fetch version is because github changes the version frequently and that cause issue in the runner – Irfan Pathan Oct 18 '22 at 08:16
  • You seem to be trying to redirect to a file with an empty name when using `>> ${GITHUB_RUNNER_VERSION}`. I guess what you want to do is have the result stored in the variable `GITHUB_RUNNER_VERSION`, but that's not what this command does. Check [this article](https://vsupalov.com/set-dynamic-environment-variable-during-docker-image-build/). – Joachim Sauer Oct 18 '22 at 08:26
  • @JoachimSauer I tried referring to the article u shared. ``` RUN $(curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]') > /root/tmp_variable RUN GITHUB_RUNNER_VERSION=$(cat /root/tmp_variable); ``` i got this error still: Step 9/21 : RUN $(curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]') > /root/tmp_variable ---> Running in 38bdae63f3b8 /bin/sh: 1: 2.298.2: not found exit status 127 – Irfan Pathan Oct 18 '22 at 11:12
  • It's pretty hard to read code and error messages in content. Please [edit] your question to include your attempt and the output. At first glance it looks like you've got a pointless command subsitution `$(...)` in there. You should have just `some_command > /target/file`. Because `$(some_command) > /target/file` would try to *interpret the output of `some_command` as a command itself and *run* it. – Joachim Sauer Oct 18 '22 at 11:36

0 Answers0