Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use single YAML for multiple triggers and builds.

Scott Emberson
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!
November 15, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
November 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
AUG Leaders

Atlassian Community Events