This is the first time we are implementing Continous testing using bitbucket pipeline. We are getting compilation error while modifyiing bitbucket-pipelines.yml file of dev repo to trigger test from a different repo (test repo), the file that we are modifying has code like this
Hi @Elumalai_ Gopal and welcome to the community!
Just a heads up, I edited the repo names from your post to protect your privacy. I'm going to use a numbered list to address issues:
1. Indentation like the following will work:
pipelines:
custom:
deploy to dev:
import: repo-1:main:deploy_to_dev
deploy to qa:
import: repo-1:main:deploy_to_qa
Spaces need to be used for indentation, not tabs.
2. Is the pipe part of the custom pipeline "deploy to qa"? If so, this is not supported at the moment. Additional steps or commands cannot be added to an imported pipeline. We have a feature request here https://jira.atlassian.com/browse/BCLOUD-22855 for sharing steps between different repos, this would allow you to import a step only and then add a second step.
The available options now are:
(a) You could add this pipe in a separate custom pipeline, different than "deploy to qa".
(b) You could look into dynamic pipelines for sharing a step: https://community.atlassian.com/forums/Forge-for-Bitbucket-Cloud/Share-a-step-across-pipelines-Dynamic-Pipelines/ba-p/2712403
(c) You could add the pipe to the definition of "deploy to qa", in the repo where you are doing the export.
(d) You could omit the import for 'deploy to qa' and just define the step and script without importing, so you can add the pipe as an additional command.
3. With regards to the pipe definition:
(a) I recommend using the latest version of the pipe, which is 5.10.1 at the moment.
(b) You need to provide authentication details to the pipe, either with the variable BITBUCKET_ACCESS_TOKEN or with the variables ATLASSIAN_ACCOUNT_EMAIL and ATLASSIAN_API_TOKEN. Please see the README.md file in the pipe's repo: https://bitbucket.org/atlassian/trigger-pipeline/src/master/ (if you scroll down, you will see the README.md)
(c) in the value of the variable CUSTOM_PIPELINE_NAME, you need to remove the part "custom: ", UNLESS this is also part of the custom pipeline's name.
If the definition of the custom pipeline in repo2 looks like this:
pipelines:
custom:
test on qa:
- variables:
- name: TestType
- step:
script:
- echo "This is test on qa pipeline"
Then you need to use CUSTOM_PIPELINE_NAME: 'test on qa' in the pipe.
Please feel free to let me know if you have any questions.
Kind regards,
Theodora
Thanks a lot for all the suggestions. Could you please provide a custom code on how to trigger a test from a destination repo (test), if the pipeline is already implemented in source repo (dev) as standard.
pipelines:
custom:
deploy to dev:
import: repo-1:main:deploy_to_dev
deploy to qa:
import: repo-1:main:deploy_to_qa
the destination repo details are as follows:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please note the destination repo also has bitbucket-pipelines.yml file with the same entries
pipelines:
custom:
deploy to dev:
import: repo-1:main:deploy_to_dev
deploy to qa:
import: repo-1:main:deploy_to_qa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Elumalai_ Gopal ,
Let's assume you have this custom pipeline in the source repo:
pipelines:
custom:
test on qa:
- variables:
- name: TestType
- step:
script:
- echo "This is test on qa pipeline, $TestType"
In the destination repo, you can add another custom pipeline, that will trigger the custom one from the source repo:
pipelines:
custom:
deploy to dev:
import: repo-1:main:deploy_to_dev
deploy to qa:
import: repo-1:main:deploy_to_qa
trigger-pipeline-in-repo-1:
- step:
script:
- pipe: atlassian/trigger-pipeline:5.10.1
variables:
BITBUCKET_ACCESS_TOKEN: $BITBUCKET_ACCESS_TOKEN
REPOSITORY: 'repo-1'
REF_TYPE: 'branch'
REF_NAME: 'release'
CUSTOM_PIPELINE_NAME: 'test on qa'
PIPELINE_VARIABLES: >
[{
"key": "TestType",
"value": "smoketest" }]
DEBUG: "true"
This is implemented as a separate custom pipeline in the destination repo (option (a) from the options I provided in my previous reply).
For the $BITBUCKET_ACCESS_TOKEN, you will need to generate a repository access token in the source repo (repo-1) from Repository settings > Access tokens that has Pipelines Write and Repositories Read permissions. Then, in the destination repo, you will need to go to Repository settings > Repository variables, create a secured variable named BITBUCKET_ACCESS_TOKEN with value the access token you created earlier. You need to have admin permissions to both repos to generate the access token and then create the variable.
If you still experience issues, you can also create a ticket with the support team for faster help. You can create a ticket via https://support.atlassian.com/contact/#/, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product. When you are asked to provide the workspace URL, please make sure you enter the URL of the workspace that is on a paid billing plan to proceed with ticket creation. Please make sure you provide the URL of a failed build or the URL or the URL of the yml that is not compiling, so my colleagues can help you faster (anything you post in the ticket won't be publicly visible).
Please feel free to let me know if you have any questions.
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.