简体   繁体   English

Azure Devops 自定义扩展和当前发布上下文

[英]Azure Devops custom extension and current release context

With Azure Devops Services, I need to get azure devops user id which triggered a release, from task.json.使用 Azure Devops Services,我需要从 task.json 获取触发发布的 azure devops 用户 ID。

I've got a datasourcebinding with Azure API Management service.我有一个与 Azure API 管理服务的数据源绑定。 This has to get Azure API Management tag based on user id.这必须根据用户 id 获取 Azure API 管理标签。 I've tried different approach:我尝试了不同的方法:

  {
    "target": "TEST",
    "endpointId": "$(ConnectedServiceName)",
    "endpointUrl": "{{endpoint.url}}/subscriptions/{{endpoint.subscriptionId}}/resourceGroups/$(ResourceGroupName)/providers/Microsoft.ApiManagement/service/$(APIM)/products?tags=**$(Release.RequestedForId)**&api-version=2019-12-01",
    "resultSelector": "jsonpath:$.value[*]",
    "resultTemplate": "{\"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{properties.displayName}}}\" }"
  },

I tried also with {{Release.RequestedForId}} but it didn't work.我也试过 {{Release.RequestedForId}} 但它没有用。

I saw different resources for datasourcebinding support:我看到了数据源绑定支持的不同资源:

tfs:teamfoundation – Any micro service hosted within TFS (eg Build, Test etc.) tfs:packaging – Packaging service tfs:feed – Feed service tfs:rm – Release Management service tfs:governance - Governance service tfs:ems - Extension Management service tfs:teamfoundation – Any micro service hosted within TFS (eg Build, Test etc.) tfs:packaging – Packaging service tfs:feed – Feed service tfs:rm – Release Management service tfs:governance - Governance service tfs:ems - Extension Management service

I found examples for tfs:feed and tfs:teamfoundation only.我找到了 tfs:feed 和 tfs:teamfoundation 的示例。

Is there any section for users?有没有供用户使用的部分? Is there any additional information apart from Azure Devops Services REST API?除了 Azure Devops Services REST API 之外还有其他信息吗?

Quite few examples in but none for user request.相当少的例子,但没有用户请求。

Is it possible to get current context release variables or azure devops user id directly in task.json?是否可以直接在 task.json 中获取当前上下文释放变量或 azure devops 用户 ID?

This would be a huge help.这将是一个巨大的帮助。

Thank you !谢谢 !

You made a small misatke.你犯了一个小错误。 Instead of Release.RequestedForId please give a try for Release.Deployment.RequestedFor of Release.Deployment.RequestedForId而不是Release.RequestedForId请尝试Release.Deployment.RequestedForRelease.Deployment.RequestedForId

Docs for Release.Deployment.RequestedFor says: Release.Deployment.RequestedFor的文档 说:

The display name of the identity that triggered (started) the deployment currently in progress.触发(启动)当前正在进行的部署的身份的显示名称。 Not available in TFS 2015.在 TFS 2015 中不可用。

Example: Mateo Escobedo示例:马特奥·埃斯科贝多

Docs for Release.Deployment.RequestedForId says: Release.Deployment.RequestedForId的文档说:

The ID of the identity that triggered (started) the deployment currently in progress.触发(启动)当前正在进行的部署的身份的 ID。 Not available in TFS 2015.在 TFS 2015 中不可用。

Example: 2f435d07-769f-4e46-849d-10d1ab9ba6ab示例:2f435d07-769f-4e46-849d-10d1ab9ba6ab

You have this written here .你有这个写在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM