@@ -161,6 +161,18 @@ export const generateServiceBuildAndUpdatePipelineYaml = (
161
161
) ;
162
162
} ;
163
163
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
+
164
176
/**
165
177
* Returns a build-update-hld-pipeline.yaml string
166
178
* based on: https://github.com/andrebriggs/monorepo-example/blob/master/service-A/azure-pipelines.yml
@@ -176,15 +188,12 @@ export const serviceBuildAndUpdatePipeline = (
176
188
ringBranches : string [ ] ,
177
189
variableGroups ?: string [ ]
178
190
) : AzurePipelinesYaml => {
179
- const relativeServicePathFormatted = relServicePath . startsWith ( "./" )
180
- ? relServicePath
181
- : "./" + relServicePath ;
191
+ const relativeServicePathFormatted = sanitizeTriggerPath ( relServicePath ) ;
182
192
183
- // tslint:disable: object-literal-sort-keys
184
193
const pipelineYaml : AzurePipelinesYaml = {
185
194
trigger : {
186
- branches : { include : ringBranches } ,
187
- ...( relativeServicePathFormatted === "./ "
195
+ branches : { include : [ ... new Set ( ringBranches ) ] } ,
196
+ ...( relativeServicePathFormatted === ""
188
197
? { }
189
198
: { paths : { include : [ relativeServicePathFormatted ] } } )
190
199
} ,
@@ -358,7 +367,6 @@ export const serviceBuildAndUpdatePipeline = (
358
367
}
359
368
]
360
369
} ;
361
- // tslint:enable: object-literal-sort-keys
362
370
363
371
const requiredPipelineVariables = [
364
372
`'ACR_NAME' (name of your ACR)` ,
@@ -513,7 +521,6 @@ const defaultComponentYaml = (
513
521
subcomponents : [
514
522
{
515
523
name : componentName ,
516
- // tslint:disable-next-line:object-literal-sort-keys
517
524
method : "git" ,
518
525
source : componentGit ,
519
526
path : componentPath
@@ -529,8 +536,6 @@ const defaultComponentYaml = (
529
536
*/
530
537
const manifestGenerationPipelineYaml = ( ) : string => {
531
538
// 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
534
539
const pipelineYaml : AzurePipelinesYaml = {
535
540
trigger : {
536
541
branches : {
@@ -618,8 +623,6 @@ const manifestGenerationPipelineYaml = (): string => {
618
623
}
619
624
]
620
625
} ;
621
- // tslint:enable: object-literal-sort-keys
622
- // tslint:enable: no-empty
623
626
624
627
return yaml . safeDump ( pipelineYaml , { lineWidth : Number . MAX_SAFE_INTEGER } ) ;
625
628
} ;
@@ -667,8 +670,6 @@ export const generateHldLifecyclePipelineYaml = async (
667
670
} ;
668
671
669
672
const hldLifecyclePipelineYaml = ( ) : string => {
670
- // tslint:disable: object-literal-sort-keys
671
- // tslint:disable: no-empty
672
673
const pipelineyaml : AzurePipelinesYaml = {
673
674
trigger : {
674
675
branches : {
@@ -750,8 +751,6 @@ const hldLifecyclePipelineYaml = (): string => {
750
751
}
751
752
]
752
753
} ;
753
- // tslint:enable: object-literal-sort-keys
754
- // tslint:enable: no-empty
755
754
756
755
return yaml . safeDump ( pipelineyaml , { lineWidth : Number . MAX_SAFE_INTEGER } ) ;
757
756
} ;
0 commit comments