Azure devops 在发布期间将发布说明发布到TFS/VSTS Wiki
我的任务是在发布触发时自动生成并发布WIKI上的发布说明,为此我关注这篇非常方便的博客,但我的运气不佳,仍然无法使用发布模板创建WIKI页面。(同时使用Azure DevOps和TFS) 模板:Azure devops 在发布期间将发布说明发布到TFS/VSTS Wiki,azure-devops,markdown,azure-pipelines,wiki,release-notes,Azure Devops,Markdown,Azure Pipelines,Wiki,Release Notes,我的任务是在发布触发时自动生成并发布WIKI上的发布说明,为此我关注这篇非常方便的博客,但我的运气不佳,仍然无法使用发布模板创建WIKI页面。(同时使用Azure DevOps和TFS) 模板: **Build Number** : $($build.buildnumber) **Build started** : $("{0:dd/MM/yy HH:mm:ss}" -f [datetime]$build.startTime) **Source Bran
**Build Number** : $($build.buildnumber)
**Build started** : $("{0:dd/MM/yy HH:mm:ss}" -f [datetime]$build.startTime)
**Source Branch** : $($build.sourceBranch)
###Associated work items
@@WILOOP@@
* #$($widetail.id)
@@WILOOP@@
###Associated change sets/commits
@@CSLOOP@@
* **ID $($csdetail.changesetid)$($csdetail.commitid)**
>$($csdetail.comment)
@@CSLOOP@@
PowerShell脚本
$content = [IO.File]::ReadAllText("$(System.DefaultWorkingDirectory)\releasenotes.md")
$data = @{content=$content;} | ConvertTo-Json;
$params = @{uri = '$(WikiPath)';
Method = 'PUT';
Headers = @{Authorization = "Bearer $(System.AccessToken)" };
ContentType = "application/json";
Body = $data;
}
Invoke-WebRequest @params
请告诉我我做错了什么检查工作级别上对
系统的访问权限。AccessToken
:
此外,请检查wiki上的权限
在作业级别检查对
系统的访问权限。AccessToken
:
此外,请检查wiki上的权限
测试后,我们发现您提到的PowerShell脚本使用以下Rest API:,因此wikipath是请求的url,格式如下:
https://dev.azure.com/{organization}/{project}/_-api/wiki/wikis/{wikiIdentifier}/pages?path={path}&api version=6.0
例如,我们创建一个名为scrum test.wiki的项目wiki,并希望创建一个名为Release notes的新wiki页面,url如下所示
https://dev.azure.com/{organization}/{project}/_-api/wiki/wikis/scrum-test.wiki/pages?path=Release notes&api version=6.0
如果我们现在想在发行说明页面下创建一个名为0.1.0的子wiki页面,url如下所示
https://dev.azure.com/{organization}/{project}/_-api/wiki/wikis/scrum-test.wiki/pages?path=Release-notes/0.1.0&api-version=6.0
此外,使用AccessToken时,我们总是会收到错误消息,“wiki页面操作失败,消息为:用户没有此wiki的写入权限。”
即使我们授予标识的完整wiki权限:{project name}生成服务({organization name}),因此,我们使用的是完全访问,它可以很好地与下面的PowerShell脚本配合使用
$content = [IO.File]::ReadAllText("$(System.DefaultWorkingDirectory)\releasenotes.md")
$data = @{content=$content;} | ConvertTo-Json;
$connectionToken="PAT here"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$params = @{uri = '$(WikiPath)';
Method = 'PUT';
Headers = @{Authorization = "Basic $base64AuthInfo" };
ContentType = "application/json";
Body = $data;
}
Invoke-WebRequest @params
测试后,我们发现您提到的PowerShell脚本使用以下Rest API:,因此wikipath是请求的url,格式如下:
https://dev.azure.com/{organization}/{project}/_-api/wiki/wikis/{wikiIdentifier}/pages?path={path}&api version=6.0
例如,我们创建一个名为scrum test.wiki的项目wiki,并希望创建一个名为Release notes的新wiki页面,url如下所示
https://dev.azure.com/{organization}/{project}/_-api/wiki/wikis/scrum-test.wiki/pages?path=Release notes&api version=6.0
如果我们现在想在发行说明页面下创建一个名为0.1.0的子wiki页面,url如下所示
https://dev.azure.com/{organization}/{project}/_-api/wiki/wikis/scrum-test.wiki/pages?path=Release-notes/0.1.0&api-version=6.0
此外,使用AccessToken时,我们总是会收到错误消息,“wiki页面操作失败,消息为:用户没有此wiki的写入权限。”
即使我们授予标识的完整wiki权限:{project name}生成服务({organization name}),因此,我们使用的是完全访问,它可以很好地与下面的PowerShell脚本配合使用
$content = [IO.File]::ReadAllText("$(System.DefaultWorkingDirectory)\releasenotes.md")
$data = @{content=$content;} | ConvertTo-Json;
$connectionToken="PAT here"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$params = @{uri = '$(WikiPath)';
Method = 'PUT';
Headers = @{Authorization = "Basic $base64AuthInfo" };
ContentType = "application/json";
Body = $data;
}
Invoke-WebRequest @params
很好的捕获,现在我的日志显示状态代码:200和状态描述:OK,但仍然没有创建WIKI页面:(你能告诉我PS中消耗的$(WikiPath)的值吗script@SaadAwan,我没有使用此扩展,只能提出一些想法)。检查wiki安全上生成服务的权限。很好,现在我的日志显示状态代码:200和状态描述:OK,但仍然没有创建wiki页面:(请将PS中消耗的$(WikiPath)的值与我共享好吗script@SaadAwan,我没有使用此扩展,只能提出一些想法)。检查wiki安全上生成服务的权限。感谢所有人,$(WikiPath)是问题所在,更正了链接,现在可以按预期创建wiki页面,感谢所有人,$(WikiPath)是问题所在,更正了链接,现在可以按预期创建wiki页面,