I'm unable to execute some commands however I have installed their packages but in different steps, the same commands are working fine if I'm installing their packages in the same step
the yml script below is throwing an error in the second step, as
bash: curl: command not found
if i moved curl installation to 2nd step it will work fine
image: ubuntu:latest
pipelines:
default:
- step:
name: Install Environment Dependencies
script:
- apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl sudo wget
- step:
name: Install Nodejs
script:
- |
curl -sL https://deb.nodesource.com/setup_14.x | bash && \
apt-get -qqy install nodejs && \
exit 0 && \
npm cache clean && \
apt-get remove --purge -y npm && \
apt-get autoremove --purge -y
Hi @Amr Salem and welcome to the community.
For each Pipelines step in your yaml file, a Docker container starts with the image you specify (if you don't, the default image https://hub.docker.com/r/atlassian/default-image/ will be used), then the commands in the script of this step are executed, and then this Docker container gets destroyed.
The reason why curl is not found if you install it in a separate step is because curl will be installed in the Docker container of that specific step. Then the container for this step will get destroyed, and a new one will start for the next step.
If you need a specific tool in a step that is not already pre-installed in the Docker image you use, you will need to install it in the step that uses it.
I hope this helps to clarify things. Please feel free to let me know if you have any questions!
Kind regards,
Theodora
Thanks for the answer, I get it now.
I'm just concerning if there is a way to label or name specific commands instead of keep listing all commands one after another
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Amr Salem,
Thank you for your reply.
I'm afraid that we don't have a way to label or name specific commands.
Bitbucket Pipelines uses YAML. With YAML anchors, you can label/name a step and reuse it, you can see an example here:
However, it is not possible to have multiple anchors in one step, i.e. one anchor for each command, and then reference multiple anchors in the same step.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.