Answers: <p>You can do:</p>
  <pre class="lang-yaml prettyprint-override"><code>variables:
    templates.ref: $[ resources.repositories['templates'].ref ]
  </code></pre>
  <p>See <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#repository-details" rel="nofollow noreferrer">Repository Details docs</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-04-20T06:44:05.647Z
Answers: Thanks, I didn't know that. The problem though is that I have to know that exact name that was used to include our repo (`templates` in this example) in order to access the correct resource's properties. Do you know of an approach that would allow me to access a property in `$[ resources.repositories[*]` based on the `name` property? of a repository resource?
Answers: Walter Vos
Answers: CC BY-SA 4.0
Answers: 2021-04-20T07:44:14.353Z
Answers: I don't think there's a way to do it in yaml. 
  You could enforce the resource name by having a step with `condition: eq(variables['templates.ref'], '')` that would do something like `throw "Please name the referenced repostiory as 'template'"`
Answers: qbik
Answers: CC BY-SA 4.0
Answers: 2021-04-19T06:41:31.503Z
Answers: 2021-04-19T06:41:31.503Z
Answers: qbik
Body: <p>I work in a platform team that builds and supports Azure Pipelines YAML templates and various custom scripting for these pipelines. People in my organisation use these YAML templates like:</p>
  <pre><code>resources:
    repositories:
      - repository: templates
        type: git
        name: PROJECT/cicd_stuff
        ref: refs/heads/releases/v0.21
  extends:
    template: our_awesome_template.yml@templates
    parameters:
      ...
  </code></pre>
  <p>In order to reliably match the version of our scripts to the version of the YAML templates, we now include an extra build stage in our pipeline templates that checks out the repo <code>templates</code> repo and puts all our scripts in an artifact to be used in that run. Using &quot;release branches&quot; allows us to safely put out and test new features and fixes to our pipelines: Teams can upgrade their pipeline on their own pace, with older version remaining supported for a while.</p>
  <p>I'd like to start using Azure Artifacts for our script artifacts, but now I'm wondering &quot;how can I determine which version of my scripts I should be downloading from Azure Artifacts?&quot; The information included in the <code>resources</code> block would work for me, but I can't seem to access that with an expression or with a predefined variable. The only solution I can currently think of is to use the az pipelines cli. Any thoughts?</p>
  
Tags: <azure-devops><azure-pipelines><yaml>
Title: How to get information about resources in an Azure Pipelines run?
UserDisplayName: Walter Vos
ThreadText: # How to get information about resources in an Azure Pipelines run?
  
  (Asked by: username_0 on 2021-04-13)
  
  I work in a platform team that builds and supports Azure Pipelines YAML templates and various custom scripting for these pipelines. People in my organisation use these YAML templates like:
  
  ```
  resources:
    repositories:
      - repository: templates
        type: git
        name: PROJECT/cicd_stuff
        ref: refs/heads/releases/v0.21
  extends:
    template: our_awesome_template.yml@templates
    parameters:
      ...
  
  ```
  
  In order to reliably match the version of our scripts to the version of the YAML templates, we now include an extra build stage in our pipeline templates that checks out the repo `templates` repo and puts all our scripts in an artifact to be used in that run. Using "release branches" allows us to safely put out and test new features and fixes to our pipelines: Teams can upgrade their pipeline on their own pace, with older version remaining supported for a while.
  
  I'd like to start using Azure Artifacts for our script artifacts, but now I'm wondering "how can I determine which version of my scripts I should be downloading from Azure Artifacts?" The information included in the `resources` block would work for me, but I can't seem to access that with an expression or with a predefined variable. The only solution I can currently think of is to use the az pipelines cli. Any thoughts?
  
  **Tags:** azure-devops, azure-pipelines, yaml
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-04-19. Score: 4 | Accepted answer
  
  You can do:
  
  ```yaml
  variables:
    templates.ref: $[ resources.repositories['templates'].ref ]
  
  ```
  
  See [Repository Details docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#repository-details).
  
  > **Comments:**
  > **username_0**: Thanks, I didn't know that. The problem though is that I have to know that exact name that was used to include our repo (`templates` in this example) in order to access the correct resource's properties. Do you know of an approach that would allow me to access a property in `$[ resources.repositories[*]` based on the `name` property? of a repository resource?  
  > **username_1**: I don't think there's a way to do it in yaml.  You could enforce the resource name by having a step with `condition: eq(variables['templates.ref'], '')` that would do something like `throw "Please name the referenced repostiory as 'template'"`  
  
  ---
  
  