Skip to content

Commit

Permalink
use relative path within same context #224 (#225)
Browse files Browse the repository at this point in the history
* use relative path within same context #224

* added tests

* updated test case to reflect scoped relative paths. #224
  • Loading branch information
bryanbcook authored Oct 6, 2023
1 parent c09a0ce commit 84b5652
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ jobs:
gharun --event azpipelines -C testworkflows/azpipelines/version-literal -W testworkflows/azpipelines/version-literal/pipeline.yml
gharun --event azpipelines -C testworkflows/azpipelines/relative-and-absolute-paths -W testworkflows/azpipelines/relative-and-absolute-paths/pipeline.yml
gharun --event azpipelines -C testworkflows/azpipelines/null-each-loop -W testworkflows/azpipelines/null-each-loop/pipeline.yml
gharun --event azpipelines -C testworkflows/azpipelines/cross-repo-relative-paths/repo1 -W testworkflows/azpipelines/cross-repo-relative-paths/repo1/pipeline.yml --local-repository central/shared@main=testworkflows/azpipelines/cross-repo-relative-paths/repo2
- name: Windows Container Change Firewall Settings
if: contains(matrix.os, 'windows') && !job.container
run: |
Expand Down
2 changes: 1 addition & 1 deletion src/Sdk/AzurePipelines/AzureDevops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public static MappingToken ReadTemplate(Runner.Server.Azure.Devops.Context conte
var fileId = templateContext.GetFileId(filename);
// Read the file
var finalRepository = afilenameAndRef.Length == 1 ? context.RepositoryAndRef : string.Equals(afilenameAndRef[1], "self", StringComparison.OrdinalIgnoreCase) ? null : context.Repositories.TryGetValue(afilenameAndRef[1], out var ralias) ? ralias : throw new Exception($"Couldn't find repository with alias {afilenameAndRef[1]} in repository resources");
var finalFileName = afilenameAndRef.Length == 1 ? RelativeTo(context.CWD ?? ".", filename) : filename;
var finalFileName = context.RepositoryAndRef == finalRepository ? RelativeTo(context.CWD ?? ".", filename) : filename;
if(finalFileName == null) {
throw new Exception($"Couldn't find template location {filenameAndRef}");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
repositories:
- repository: shared
name: central/shared
type: git
ref: main

jobs:
- template: /templates/job.yml@shared
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

jobs:
- job: job1
steps:
- template: step.yml@shared # scoped relative path
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
steps:
- script: exit 0

0 comments on commit 84b5652

Please sign in to comment.