Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,560,634
Community Members
 
Community Events
185
Community Groups

How to divide reusable tasks yet using a single Docker container?

Hello there !

I am new to Bitbucket pipelines coming from Jenkins.
I want to have a pipeline with the following tasks:

  1. Setup Javascript dependencies
  2. Lint code
  3. Generate doc
  4. Execute tests
  5. Report tests results to PR

I implemented those tasks using multiple step .
All steps are using the same Docker container which is cached and restored for each step. This process of caching/restoring is time consuming.
Also, those steps are defined and then used as YAML anchors and references to avoid duplication: reshuffled steps depending on the branch (a feature branch, develop, main, …).

My question: Is there a way to get all the following:

  • Simple tasks reusable (just like step and YAML reference)
  • All tasks using the same Docker container without cache/restore
  • Visual representation in the Pipeline layout of the individual tasks to quickly identify where the issue, if any, was raised.

Thanks for your support !

 

1 answer

0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 24, 2023

Hi @Fabien Lydoire 

If your commands are one-line, just have one step per branch type/group and run them together.

If the commands are more complex, my recommendation is to implement these tasks externally to the pipeline/steps, IE, use a build script: gradle, maven, sh file, etc'. This will simplify the commands, or even group of commands, to one-liners and you can use the first option. 

one step per branch (...) and run them together

Yes I can do that, but it does not match my third requirement:

  • Visual representation in the Pipeline layout of the individual tasks to quickly identify where the issue, if any, was raised.

Having a single step means having a single node in the Pipeline graph. I wish I could split tasks within a single node.

Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 25, 2023

Here is the visual representation you would have:

Screenshot 2023-04-25 at 10.14.41.png

You can see each command has its own line so it's very easy to see which one failed.

Basically, each step in the pipeline is running on a different container. if you need to share data between the steps, you would need to use cache/artifacts mechanism or some other way to inject the data into the containers (git clone/ftp/download/etc'). 

Thanks @Erez Maadani I understand that there are no better options.

I implemented my Bitbucket pipeline according to your suggestion.

I saves run time, yet I'm still frustrated with the single step green bullet in the pipeline graphical view.... 🤷🏻‍♂️

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events