Buildkite use shell variables in global hook

122 views Asked by At

I used a variable in my pipeline script like this.

# This shell is a pipeline shell script

export container_id=`docker run -d MY_CONTAINER`

then regardless of the success of the result, I want to remove my container using container_id, like this.

# This shell is a global exit hook

docker rm ${docker stop $container_id}

but it does not work. What can I do to solve this problem?

1

There are 1 answers

0
Arkadiusz Drabczyk On BEST ANSWER

Use command substitution:

docker rm $(docker stop $container_id)