@@ -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 : {
@@ -612,8 +617,6 @@ const manifestGenerationPipelineYaml = (): string => {
612617 }
613618 ]
614619 } ;
615- // tslint:enable: object-literal-sort-keys
616- // tslint:enable: no-empty
617620
618621 return yaml . safeDump ( pipelineYaml , { lineWidth : Number . MAX_SAFE_INTEGER } ) ;
619622} ;
@@ -661,8 +664,6 @@ export const generateHldLifecyclePipelineYaml = async (
661664} ;
662665
663666const hldLifecyclePipelineYaml = ( ) : string => {
664- // tslint:disable: object-literal-sort-keys
665- // tslint:disable: no-empty
666667 const pipelineyaml : AzurePipelinesYaml = {
667668 trigger : {
668669 branches : {
@@ -744,8 +745,6 @@ const hldLifecyclePipelineYaml = (): string => {
744745 }
745746 ]
746747 } ;
747- // tslint:enable: object-literal-sort-keys
748- // tslint:enable: no-empty
749748
750749 return yaml . safeDump ( pipelineyaml , { lineWidth : Number . MAX_SAFE_INTEGER } ) ;
751750} ;
0 commit comments