Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,294,582
Community Members
 
Community Events
165
Community Groups

Unable to use commands in different steps?

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

1 answer

1 accepted

0 votes
Answer accepted

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

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

Like Amr Salem likes this

great thank you

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,158 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you