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,554,246
Community Members
 
Community Events
184
Community Groups

Run only one pipeline at time

Hello, 

 

I use bitbucket pipelines for E2E testing on my remote server. Pipleline deploys code to test serverer and runs all tests. It works just fine. But when multiple pipeliens starts, collision happends. I have only one test server and I cant create new one for each pipeline, so second pipeline replace code on server and first  pipeline usually fails. 

Is there any way to wait until previous pipeline is finished? Or any other workaround? thanks!

2 answers

1 accepted

0 votes
Answer accepted

@Patrik S  Thanks for reply.  No, that is not it. I have something like this: 

- step:
name: Deploy to test
deployment: test
script:
- echo "Deploying to test environment"
- pipe: atlassian/ssh-run:0.2.2
variables:
SSH_USER: 'admin'
SERVER: 'example.com'
COMMAND: './deploy --branch=$BITBUCKET_BRANCH'
- step:
name: Cypress - E2E testing
image: cypress/included:9.5.1
script:
- npx cypress run

 

When multiple piplenes are running, second pipeline rewrite deployment on first and E2E tests fails on first pipeline. 

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jun 09, 2022

Hello @petr-hudik ,

In this case, as we currently do not support multi-step deployments, my suggestion of a workaround would be to have the deploy and E2E testing in the same step, like below : 

- step:
name: Deploy to test and Cypress - E2E testing
image: cypress/included:9.5.1
deployment: test
script:
- echo "Deploying to test environment"
- pipe: atlassian/ssh-run:0.2.2
variables:
SSH_USER: 'admin'
SERVER: 'example.com'
COMMAND: './deploy --branch=$BITBUCKET_BRANCH'
- npx cypress run

As the step above is set up as a deployment (because it is using the deployment keyword), if multiple pipelines are triggered and deploy to the same environment, only the first one will be executed, and the other pipelines will be paused. Once one of the concurrent pipelines is complete, you can manually resume the paused ones.

Hope that helps! Let me know if you have any questions.

Thank you, @petr-hudik 

Kind regards,

Patrik S

That is so cool! it works! thanks, that is exactly what i wanted!

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 26, 2021 • edited

Hello Petr,

Reviewing your case my understanding is that you do not want more than one instance of your pipeline running concurrently because you have just one deployment environment.

In order to avoid that concurrency I would recommend you tracking your deployments by using the Bitbucket Deployments. This way whenever a pipeline step starts a new deployment to a given environment, Bitbucket will first check if there's any other deployment already running to that same environment.

If there's already a deployment in progress, the later pipeline deployment to the same environment will be paused. Once one of the concurrent pipelines complete, you can manually resume the paused one.

So in your case, I'd suggest setting up a deployment environment in your yml to the steps that are sensitive to concurrency by adding the deployment option :

- step:
    name: Deploy to test
    image: atlassian/default-image:3
    deployment: test
    script:
      - python deploy.py test

You can check and change your repository's deployment environments going to :

  • Repository settings.
  • In the Pipelines section, choose Deployments

There you will be allowed to change environment name, set environment variables and restrict the ability to deployments.

Also, you can refer to this documentation for more details about setting up deployment environments :

And to this one for  Deployment concurrency control  :

Please, let me know if this suggestion works for you :)

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events