首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GitVersion、热修复和拉取请求

GitVersion、热修复和拉取请求
EN

Stack Overflow用户
提问于 2021-01-13 13:27:57
回答 2查看 128关注 0票数 0

我在Azure DevOps中有一个设置,正在尝试配置GitVersion来执行我们的版本控制。工作正常,除了热修复程序的拉取请求

示例: hotfix分支的构建版本为1.2.3-beta...hotfix分支启动拉取请求给出MED1.3.0-PullRequest

我预计是1.2.3-PullRequest。

我做错了什么??

EN

回答 2

Stack Overflow用户

发布于 2021-01-13 16:55:02

如何在拉入请求的构建管道定义中设置内部版本号?

根据您的评论,您希望PR的内部版本号与hotfix分支的最新内部版本号相同,但后缀除外,对吧?

如果是这样,您可以尝试在PR的构建管道中设置并运行shell脚本(此处以PowerShell为例),如下所示。

代码语言:javascript
复制
# Convernt PAT to Base64 string
$pat = "personal access token"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "", $pat)))

# Set up headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", ("Basic {0}" -f $base64AuthInfo))
$headers.Add("Content-Type", "application/json")

$uri = "https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitionID}&branchName=$(System.PullRequest.SourceBranch)&`$top=1&api-version=6.1-preview.6"

# Run the API and return the response body
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method GET

# Get buildNumber of the latest build for hotfix branch
$buildNumber_hotfix = $response.value[0].buildNumber
Write-Host "$buildNumber_hotfix"

# Replace the suffix
$buildNumber_PR = $buildNumber_hotfix.replace("beta","PullRequest")
Write-Host "$buildNumber_PR"

# Update the buildNumber of current build for the PR
Write-Host "##vso[build.updatebuildnumber]$buildNumber_PR"

描述:

REST API "".中的

  1. 参数

代码语言:javascript
复制
- The '**`definitionID`**' is the ID of the build pipeline for hotfix branch.
- The '**`branchName`**' is the source branch of the PR (e.g. **`refs/heads/hotfix`**), you can directly use the [predefined variable](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#system-variables-devops-services) '**`$(System.PullRequest.SourceBranch)`**' to get the branch name.
- Set the value of '**`$top`**' as **`1`**. This will let the API call only return the latest build.

票数 1
EN

Stack Overflow用户

发布于 2022-03-02 19:34:10

您需要使用的是默认的gitversion配置,您可以使用gitversion init进行配置。

每个PR递增patch版本- 1.1.1。因此,每个PR都被认为是一个热修复。然后,您需要做的是添加提交消息+semver:minor以提升minor版本- 1.2.0。如果您希望将其保留为热修复程序,请不要包含提交消息。

然后将构建从main升级到您的实时环境,并使用1.2.0手动或自动标记您的main分支。

这里假设您使用的是默认的ContinuousDelivery模式。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65696119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档