0

I have a Docker image setup to run a simple script that I am running via copilot task run.

FROM node:12-alpine
RUN apk update
RUN apk add curl
RUN apk add jq
RUN apk add --no-cache aws-cli
COPY deploy-permissions.sh /usr/local/bin/deploy-permissions.sh
RUN chmod +x /usr/local/bin/deploy-permissions.sh
ENTRYPOINT ["/usr/local/bin/deploy-permissions.sh"]

When I run it via copilot task run with the --follow flag, it shows me all the log output and returns the exit code correctly.

So if I run a scenario when I know it will fail, I get

copilot task run --image %URLTOImage% --follow
echo $? (reports 1 correctly)

However, if I don't pass in --follow the command seems to complete much quicker and the exit status code is 0 regardless of whether the docker container's entrypoint script succeeds or not.

copilot task run --image %URLToImage%
echo $? (always reports 0)

The documentation says that --follow should just stream the logs, nothing about it not waiting for completion.

Am I missing something here? Why would this happen? It's causing me problems because our CI/CD pipeline is not liking the --follow option. If I could run the task without it, it'd save me some grief; however, I need the command to wait for task completion and correctly report the error code. The pipeline is currently always reporting success, which is a non-starter. If I do use --follow the Codebuild project says it the task never reaches a ready-state.

Thanks!

Adam
  • 1,202
  • 11
  • 25

1 Answers1

0

The exit code being returned when you use the --follow flag is that of the task. I believe that without the --follow flag, the exit code is that of the overarching process.

See the request here: https://github.com/aws/copilot-cli/issues/2525 and the implementation here: https://github.com/aws/copilot-cli/pull/3620. There are some interesting ideas in the issue discussion that may help you use the command in your CI/CD pipeline.

miken32
  • 42,008
  • 16
  • 111
  • 154
huanjani
  • 220
  • 1
  • 2