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

Bitbucket export/import pipelines - can you use anchors and refs to steps?

Gordon Cooke
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 25, 2023

I am looking into the (highly anticipated) functionality just released on bitbucket that allows us to export pipelines in one repo and import them to another.  We typically create re-useable steps in our `definitions:steps` section using anchor tags as supported but the yaml spec:

definitions:
steps:
step: &someBuildStep
name: step 1
...

and then later ref them in the actual pipeline:

  - step: *someBuildStep
- step: *compile
- step: *runTests

This allows us to use the steps over in distinct pipelines in a single file (and is as Atlassian documents it) 

Trying to apply this in the new import/export appears to have issues or be unsupported.  The "export" side of it passes validation and the ref from the import side appears to find the exported pipeline but reports an error :

There is an error in the imported bitbucket-pipelines.yml file. The error is at [definitions > pipelines > some-pipeline-ident > 0]. Step is empty, null, or missing.  So it does not appear to handle the anchor tags as I would expect.  Has anyone else looked at this and tried to get it working?  We  can, obviously, revert to embedding the steps in the individual pipelines but this means maintaining the same exact steps in multiple build pipelines.  Any ideas?

 

1 comment

Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 28, 2023

Hi Gordon,

Thank you for reaching out to Atlassian Support.

I'd like to inform you that anchors can be used. When I had the following configuration in the original repository

export: true

definitions:
pipelines:
share-pipeline-1:
- step: &build-test
name: Build and test
script:
- echo "Hello" >> Hello.txt
- echo "Test-1" >> Test-1.txt
- echo "Test-1" >> Test-2.txt
- echo "Test-3" >> Test-3.txt
share-pipeline-2:
- step: &second-test
name: Build and test
script:
- echo "Hello" >> Hello.txt
- echo "Test-1" >> Test-1.txt
- echo "Test-1" >> Test-2.txt
- echo "Test-3" >> Test-3.txt

I was able to link it in the other repository as

 

pipelines:
custom:
importing-pipeline:
import: reponame:branchname:share-pipeline-1

Please let us know if it helps.

Aurimas Navardauskas June 25, 2024

I have similar issue and I don't see any refs in your provided example in the importing repo, so it does not seem to be addressing the specific problem in the original question.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events