How to use single YAML for multiple triggers and builds.
Asked by Scott Emberson:

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)'


Answers:
author: Caroline R
body: Hi, [@Scott Emberson](/t5/user/viewprofilepage/user-id/4635539)! 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:

* <https://jira.atlassian.com/browse/BCLOUD-20922>

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](https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html) 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:

* <https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/>

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

Kind regards,  
Caroline


Tags: bitbucket-pipelines

cloud