cake-contrib / Cake.Recipe

:page_with_curl: A set of convention based Cake scripts
https://cake-contrib.github.io/Cake.Recipe
MIT License
70 stars 53 forks source link

Tag name in Azure Pipelines #490

Open garyng opened 5 years ago

garyng commented 5 years ago

Seems like the branch name returned by tfBuild.Environment.Repository.Branch in https://github.com/cake-contrib/Cake.Recipe/blob/faabbf5f717786e7592a12fa72be213f6d7457b8/Cake.Recipe/Content/azurepipelines.cake#L11 is not prepended with refs/tags/...

I tried printing it: image It only returns the tag name.

garyng commented 5 years ago

Will the trigger in azure-pipelines.yml affect the branch name returned?

This is what I used:

trigger:
  tags:
    include:
      - '*'
gep13 commented 5 years ago

@pascalberger do you have any insight on this one?

gep13 commented 5 years ago

@garyng it would help to know exactly what version of Cake.Recipe you are using. Can you provide that information? Are you using this on a public repository? If so, can you provide a link?

garyng commented 5 years ago

@gep13 Cake.Recipe 2.0.0-unstable0157 from myget.

Yes, I'm using it on a public repo. The relevant commit is here: https://github.com/garyng/wtfd/commit/052f40bf77e286083aac4c946392db5d6b9fc353

azure-pipelines.yml: https://github.com/garyng/wtfd/blob/052f40bf77e286083aac4c946392db5d6b9fc353/azure-pipelines.yml#L5-L7

Azure Pipelines build log for tagged commit (v0.1.0): https://dev.azure.com/garyng/wtfd/_build/results?buildId=12&view=logs&j=ca395085-040a-526b-2ce8-bdc85f692774&t=cf4477f9-109f-5399-1612-bcbe5909c9f2&l=25

In the end I replaced the IsTagged detection with GitDescribe from Cake.Git: https://github.com/garyng/wtfd/blob/c79e9c3addcd93290fff91b5ad38eaa23db1530e/cake/Cake.Recipe/Content/parameters.cake#L523

pascalberger commented 5 years ago

@gep13 tfBuild.Environment.Repository.Branch returns the value of the Build.SourceBranchName variable which is documented like this:

The name of the branch the build was queued for. Git repo branch or pull request: The last path segment in the ref. For example, in refs/heads/master this value is master. In refs/heads/feature/tools this value is tools.

There's also the Build.SourceBranch variable which is documented like this:

The branch the build was queued for. Some examples: Git repo branch: refs/heads/master Git repo pull request: refs/pull/1/merge

The Build.SourceBranch variable can be accessed through tfBuild.Environment.Repository.SourceBranch.