Skip to content

Conversation

ravenpride
Copy link
Contributor

This PR tells Azure Pipelines to export GitVersion variables across jobs. Without it the variables are only usable from within the same job. For more information on variables at Azure Pipelines, please see the official documentation.

@asbjornu asbjornu merged commit 54eaa33 into GitTools:master Jan 3, 2020
@asbjornu
Copy link
Member

asbjornu commented Jan 3, 2020

Thank you for your contributions, @ravenpride! 🙏

@jetersen
Copy link
Contributor

jetersen commented Jan 6, 2020

@ravenpride
Copy link
Contributor Author

ravenpride commented Jan 7, 2020

Within a job, you do not need to specify the name of the task. The following should suffice:

      env:
        GitVersion_Version: $(GitVersion.MajorMinorPatch)
        GitVersion_PreReleaseTagWithDash: $(GitVersion.PreReleaseTagWithDash)

If you need to pass the variables across jobs (within the same stage), it gets a bit tricky. Then you need to declare a dependency to the job that contains the task publishing the desired output variables and the output variables in a more elaborate way:

- job:
  dependsOn: <name-of-the-job-publishing-the-variables>
  env:
    GitVersion_Version: $[ dependencies.<name-of-the-job-publishing-the-variables>.outputs['<name-of-the-task/script-publishing-the-variables>.GitVersion.Version'] ]
    GitVersion_PreReleaseTagWithDash: $[ dependencies.<name-of-your-task-publishing-the-variables>.outputs['<name-of-the-task/script-publishing-the-variables>.GitVersion.PreReleaseTagWithDash'] ]

@jetersen
Copy link
Contributor

jetersen commented Jan 7, 2020

Thanks figured it out after reading the docs several time 😄

@arturcic arturcic added this to the 5.1.4 milestone Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants