@@ -161,6 +161,18 @@ export const generateServiceBuildAndUpdatePipelineYaml = (
161161 ) ;
162162} ;
163163
164+ /**
165+ * Sanitize the given path to format Azure DevOps can properly utilize
166+ *
167+ * Transforms:
168+ * - If present, removes leading dot-slash (`./`) prefix from the path
169+ *
170+ * @param pathLike a path-like string to sanitize
171+ */
172+ export const sanitizeTriggerPath = ( pathLike : string ) : string => {
173+ return pathLike . replace ( / ^ \. \/ / , "" ) ;
174+ } ;
175+
164176/**
165177 * Returns a build-update-hld-pipeline.yaml string
166178 * based on: https://github.com/andrebriggs/monorepo-example/blob/master/service-A/azure-pipelines.yml
@@ -176,15 +188,12 @@ export const serviceBuildAndUpdatePipeline = (
176188 ringBranches : string [ ] ,
177189 variableGroups ?: string [ ]
178190) : AzurePipelinesYaml => {
179- const relativeServicePathFormatted = relServicePath . startsWith ( "./" )
180- ? relServicePath
181- : "./" + relServicePath ;
191+ const relativeServicePathFormatted = sanitizeTriggerPath ( relServicePath ) ;
182192
183- // tslint:disable: object-literal-sort-keys
184193 const pipelineYaml : AzurePipelinesYaml = {
185194 trigger : {
186- branches : { include : ringBranches } ,
187- ...( relativeServicePathFormatted === "./ "
195+ branches : { include : [ ... new Set ( ringBranches ) ] } ,
196+ ...( relativeServicePathFormatted === ""
188197 ? { }
189198 : { paths : { include : [ relativeServicePathFormatted ] } } )
190199 } ,
@@ -358,7 +367,6 @@ export const serviceBuildAndUpdatePipeline = (
358367 }
359368 ]
360369 } ;
361- // tslint:enable: object-literal-sort-keys
362370
363371 const requiredPipelineVariables = [
364372 `'ACR_NAME' (name of your ACR)` ,
@@ -513,7 +521,6 @@ const defaultComponentYaml = (
513521 subcomponents : [
514522 {
515523 name : componentName ,
516- // tslint:disable-next-line:object-literal-sort-keys
517524 method : "git" ,
518525 source : componentGit ,
519526 path : componentPath
@@ -529,8 +536,6 @@ const defaultComponentYaml = (
529536 */
530537const manifestGenerationPipelineYaml = ( ) : string => {
531538 // based on https://github.com/microsoft/bedrock/blob/master/gitops/azure-devops/ManifestGeneration.md#add-azure-pipelines-build-yaml
532- // tslint:disable: object-literal-sort-keys
533- // tslint:disable: no-empty
534539 const pipelineYaml : AzurePipelinesYaml = {
535540 trigger : {
536541 branches : {
@@ -618,8 +623,6 @@ const manifestGenerationPipelineYaml = (): string => {
618623 }
619624 ]
620625 } ;
621- // tslint:enable: object-literal-sort-keys
622- // tslint:enable: no-empty
623626
624627 return yaml . safeDump ( pipelineYaml , { lineWidth : Number . MAX_SAFE_INTEGER } ) ;
625628} ;
@@ -667,8 +670,6 @@ export const generateHldLifecyclePipelineYaml = async (
667670} ;
668671
669672const hldLifecyclePipelineYaml = ( ) : string => {
670- // tslint:disable: object-literal-sort-keys
671- // tslint:disable: no-empty
672673 const pipelineyaml : AzurePipelinesYaml = {
673674 trigger : {
674675 branches : {
@@ -750,8 +751,6 @@ const hldLifecyclePipelineYaml = (): string => {
750751 }
751752 ]
752753 } ;
753- // tslint:enable: object-literal-sort-keys
754- // tslint:enable: no-empty
755754
756755 return yaml . safeDump ( pipelineyaml , { lineWidth : Number . MAX_SAFE_INTEGER } ) ;
757756} ;
0 commit comments