Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger step in Bitbucket pipelines

I have a CI pipeline in Bitbucket which is building, testing and deploying an application. The thing is that after the deploy I want to run selenium tests. Selenium tests are in an another repository in Bitbucket and they have their own pipeline.

Is there a trigger step in the Bitbucket pipeline to trigger a pipeline when a previous one has finished?

I do not want to do a fake push to the test repository to trigger those tests.

like image 934
kimy82 Avatar asked Dec 05 '22 12:12

kimy82


2 Answers

The most "correct" way I can think of doing this is to use the Bitbucket REST API to manually trigger a pipeline on the other repository, after your deployment completes.

There are several examples of how to create a pipeline here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/#post

Copy + pasting the first example. How to trigger a pipeline for the latest commit on master:

$ curl -X POST -is -u username:password \
  -H 'Content-Type: application/json' \
 https://api.bitbucket.org/2.0/repositories/jeroendr/meat-demo2/pipelines/ \
  -d '
  {
    "target": {
      "ref_type": "branch", 
      "type": "pipeline_ref_target", 
      "ref_name": "master"
    }
  }'
like image 69
phod Avatar answered Dec 28 '22 11:12

phod


according to their official documentation there is no "easy way" to do that, cause the job are isolated in scope of one repository, yet you can achieve your task in following way:

  1. create docker image with minimum required setup for execution of your tests inside
  2. upload to docker hub (or some other repo if you have such)
  3. use docker image in last step of you pipeline after deploy to execute tests
like image 31
BigGinDaHouse Avatar answered Dec 28 '22 11:12

BigGinDaHouse