0

I've created a variable group in an Azure Pipeline library. It has the password to a certificate I want to apply to signing the executables during the Azure build pipeline. I've encrypted the password by clicking on the lock icon. The problem I'm having is I've got other variables, not a part of the variable group, which I'm including in the variables section of the YAML file. I'm getting error, telling me it is an invalid YAML file. Here's what I've got:

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
  buildConfiguration: 'Release'
  Binaries: test
- group: 'acdc-pipeline-group'

I've tried to find a way of doing this, but the documentation I've found only lists the variable group by itself in the variables section. Unless I'm misunderstanding the linked documentation: Add & use variable groups

I've made a mistake in the variables, but I'm not sure what I've done wrong.

Rod
  • 4,107
  • 12
  • 57
  • 81
  • 1
    Review the documentation you linked closely. It has an example of exactly this scenario practically at the top of the page. – Daniel Mann Jun 03 '21 at 19:55

1 Answers1

1

So I think it should be something like:

variables:
- name: solution
  value: '**/*.sln'
- name: buildPlatform
  value: 'Any CPU'
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 
  value: true
- name: buildConfiguration
  value: 'Release'
- name: Binaries
  value: test
- group: 'acdc-pipeline-group'

Then you can use your variable like $(YOURVARIABLEFROMTHEGROUP) or $[variables.YOURVARIABLEFROMTHEGROUP]

Actually, that is somewhat mentioned at the docs you reference, although in a bit confusing and implicit manner and with no proper example, so let here be one :)

psfinaki
  • 1,814
  • 15
  • 29
  • That is the issue I have with the document I linked to. Thank you for your further explanation. Initially I listed the variables one per line. Then I introduced the group using "-" at the beginning of the line, per the link. Would leaving off "-" have worked? – Rod Jun 03 '21 at 21:39
  • 1
    You're welcome. For your question, well you can try (regretfully that's the best thing to do with YAML anyway) but I don't think it will work - variables are basically a YAML sequence and these dashes are a way to enumerate the items. Another way is to put all the items within square brackets (as described [here](https://stackoverflow.com/q/23657086/3232646)) but that would worsen the readability in your case. – psfinaki Jun 03 '21 at 21:49