我在Azure DevOps中有一个设置,正在尝试配置GitVersion来执行我们的版本控制。工作正常,除了热修复程序的拉取请求
示例: hotfix分支的构建版本为1.2.3-beta...hotfix分支启动拉取请求给出MED1.3.0-PullRequest
我预计是1.2.3-PullRequest。
我做错了什么??
发布于 2021-01-13 16:55:02
如何在拉入请求的构建管道定义中设置内部版本号?
根据您的评论,您希望PR的内部版本号与hotfix分支的最新内部版本号相同,但后缀除外,对吧?
如果是这样,您可以尝试在PR的构建管道中设置并运行shell脚本(此处以PowerShell为例),如下所示。
# 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 "".中的
- 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.发布于 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模式。
https://stackoverflow.com/questions/65696119
复制相似问题