Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a release pipeline in Azure DevOps that creates a GitHub release every time?

I get this warning when the pipeline runs:

Release will not be created as the tags for the target commit do not match with the given tag pattern.

Thing is, the Tag Pattern property of the GitHub release is blank; I'm not setting any particular tag pattern. How do I skip this warning so the release can be created every time the pipeline runs?

like image 675
ekolis Avatar asked Sep 22 '19 22:09

ekolis


People also ask

How do I create a release pipeline in Azure DevOps?

Click to get started building your first release pipeline! On the release pipelines page go to new, and select new release pipeline . There are many templates that Azure DevOps offers. This screen will appear and you’ll have the option to use a template or create an empty job.

How does Azure pipeline work?

Azure Pipelines releases can deploy artifacts that are produced by a wide range of artifact sources such as Azure Pipelines build, Jenkins, or Team City. You define the release pipeline using stages, and restrict deployments into or out of a stage using approvals.

How to use GitHub with Azure DevOps?

When using GitHub with Azure DevOps $ (Build.SourceVersion) contains the commit id. See Microsoft docs, Predefined variables for a list of variables. Use $ (Build.BuildNumber) to use the version number used in the build. Define the release title, the title is shown in the header on GitHub releases page.

How do I create a GitHub service in azure pipelines?

Azure Pipelines. Use this task in your pipeline to create, edit, or discard a GitHub release. This task requires a GitHub service connection with Write permission to the GitHub repository. You can create a GitHub service connection in your Azure Pipelines project. Once created, use the name of the service connection in this task's settings.


1 Answers

How do I make a release pipeline in Azure DevOps that creates a GitHub release every time?

I could reproduce this issue on my side, if I leave the Tag Pattern property of the GitHub release is blank.

That because this property is Required. Check the GitHub Release task:

Tag source (Required) Configure the tag to be used for release creation. The 'Git tag' option automatically takes the tag which is associated with this commit. Use the 'User specified tag' option in case you want to manually provide a tag.

As the description above, the 'Git tag' option automatically takes the tag which is

associated with this commit.

So, if we leave that property Tag Pattern is blank, the value is null, but the commit id is not null, then you will get this error. Check my detailed build log:

enter image description here

To resolve this issue, we could give the Tag Pattern with the commit ID. Or you could use the another option User specified tag, then you can manually provide a tag, like release-v1.0.

As test, it works fine on my side.

Update:

but I want the pipeline to run every time someone pushes or merges code into the master branch; I don't want to have to specify a tag for each commit

If you do not want to have to specify a tag for each commit, you can use counter expressions in Variables, like:

variables:
  MajorVersion: 1
  MinorVersion: 0
  InitialReleaseTagNumber: 1
  IncrementReleaseTagNumber: $[counter(variables['InitialReleaseTagNumber'], 0)]

Then we set v$(MajorVersion).$(MinorVersion).$(IncrementReleaseTagNumber) following in the tag option:

enter image description here

So, the value of the tag will increase by 1 once the build runs.

Hope this helps.

like image 81
Leo Liu-MSFT Avatar answered Nov 15 '22 09:11

Leo Liu-MSFT