Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use single YAML for multiple triggers and builds.

Hi, so I am trying to reverse engineer my YAML what was built for Azure DevOps Pipelines. It simply ran a PowerShell script to stamp some PowerShell scripts, package the selected file into a NuGet package and pushed to Octopus.
How it was built in Azure DevOps was multiple pipelines calling a single YAML. This enabled me to pass in different variables, aka the script's name for the NuGet package, and I could also trigger the single script overbuilding everything every time. 

Is there any way to replicate this in Bitbucket?

This is the Azure DevOps YAML.

variables:
NuGetPackageID: 'Infrastructure-$(ProjectName)'
NuGetPackageVersionNumber: '$(VersionNumber)-$(CodeChangeID)-$(Build.BuildNumber)'

jobs:
- job: BuildProject
displayName: Build and create package
continueOnError: false
workspace:
clean: resources
steps:
- task: DevOps-StampVersionDetails.DevOps.StampVersionDetails.DevOps.StampVersionDetails@1
displayName: 'Stamp Version Details '
inputs:
InputSourceControlType: GIT
InputVersionStyle: 9
InputProductType: CloudFormation
InputProject: '$(ProjectName)'
InputStampAssembly: false
InputStampSQL: false
InputStampCsproj: true
InputStampCsprojCustom: true
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- task: CopyFiles@2
displayName: 'Copy CloudFormation file to artifact staging director'
inputs:
SourceFolder: '$(Build.SourcesDirectory)\'
Contents: '**\*-$(ProjectName).yml'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true

- task: octopusdeploy.octopus-deploy-build-release-tasks.octopus-pack.OctopusPack@4
displayName: 'Package $(ProjectName) into NuGet package'
inputs:
PackageId: '$(NuGetPackageID)'
PackageVersion: '$(NuGetPackageVersionNumber)'
SourcePath: '$(Build.ArtifactStagingDirectory)'
OutputPath: '$(Build.ArtifactStagingDirectory)'
NuGetAuthor: 'Company Name'
NuGetTitle: '$(NuGetPackageID)'
NuGetDescription: 'Created by build: $(Build.BuildNumber)'
Include: |
*.yml

- task: octopusdeploy.octopus-deploy-build-release-tasks.octopus-metadata.OctopusMetadata@4
displayName: 'Push Package Build Information to Octopus'
inputs:
OctoConnectedServiceName: 'Octopus'
Space: Default
PackageId: '$(NuGetPackageID)'
PackageVersion: '$(NuGetPackageVersionNumber)'
Replace: true

- task: DeleteFiles@1
displayName: 'Clean artifact staging directory before publishing'
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)'
Contents: |
*-$(ProjectName).yml
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: $(Build.BuildNumber)'
inputs:
ArtifactName: '$(Build.BuildNumber)'

1 answer

0 votes
Caroline R Atlassian Team Nov 22, 2021

Hi, @Scott Emberson! Welcome to the community! 

I understand you have two different questions here:

How it was built in Azure DevOps was multiple pipelines calling a single YAML

For the first one, we have the following feature request to allow users to consume bitbucket-pipelines.yml files from multiple repositories:

I would suggest that you add your vote there (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features. 

You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

Implementation of new features is done as per our policy here and any updates will be posted in the feature request. 

For the second one:

This enabled me to pass in different variables, aka the script’s name for the NuGet package, and I could also trigger the single script overbuilding everything every time.

We have the following doc that explains how you can set variables:

Please let us know if this is helpful and feel free to correct us in case we have misunderstood something here.

Kind regards,
Caroline

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,436 views 4 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you