将数据填充到VSTS发布摘要选项卡中 [英] Populate data in to VSTS release summary tab

本文介绍了将数据填充到VSTS发布摘要选项卡中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个发布而不在TFS/VSTS中映射现有的构建,并在完成后使数据显示在发布摘要中.以纯文本格式显示的步骤是

I am trying to create a release without mapping a existing build in TFS/VSTS and get data display in release summary once it is completed. in plain text steps are following

  • 发布->空发布定义->添加构建任务->创建发布->部署->在摘要"部分中查看数据

汇总数据可以按预期查看,在以下两种情况下不会出现任何问题

Summary data are view-able as expected without any issues with following two scenarios

  1. 构建->创建构建定义->添加任务->保存并排队构建–构建成功->查看摘要数据
  2. 发布->空发布定义->链接预定义的构建定义->创建发布->提供成功运行的构建版本->查看摘要数据.

根据我们的理解,当我们检索给定版本的工件时,就会出现此问题.我们可以检索构建的结果,但对于发行版则无法这样做.以下是我们用于读取发布数据的示例代码.如果您可以为我们提供有关给定发行版的工件详细信息的检索指南,将非常有帮助.现在,我们在客户端使用以下代码来获取发布工件,但是它抱怨release.artifacts是未定义的.我们已验证附件文件已保存到给定的文件位置.

As As per our understanding the issue occurs when we retrieving artifacts of the given release. We can retrieve results for builds but fail to do the same for releases. Below is the sample code we use to read release data. It will be much helpful if you can provide us guidance on retrieving artifacts details for given release. Right now we use following code in the client side for retrieving release artifacts but it complains release.artifacts is undefined. We have verified that the attachment file is saved to the given file location.

var c = VSS.getConfiguration();
c.onReleaseChanged(function (release) {
         release.artifacts.forEach(function (art) {
                var buildid = art.definitionReference.version.id;
// rest of the code is removed here

         });
});

下面是我们用来查找解决方案的参考

below are the references we followed to find solution,

如何从中检索构建附件VSTS发布摘要标签

https://www.visualstudio.com/zh-CN/docs/integrate/extensions/reference/client/core-sdk#method_getConfiguration

推荐答案

我能够找到此问题的答案.我特此与大家分享.

I was able to figure out an answer for this issue. I am herewith sharing same for others reference.

如果我们不链接工件(构建定义),那么发布/发布定义的工件将不会填充数据,因此我们将无法引用作为一部分上传的附件的构建.

If we don’t link an artifact(build definition), then the artifacts for the release/release definition will not be filled with the data, so we won’t be able to refer to the attachment that got uploaded as part of the build.

因此,根据当前的API实现,以下是实现此要求的步骤.

Hence as per current API implementation, Below are the steps to follow to achieve this requirenment.

  • 在扩展程序作为构建任务运行时将数据写入日志
  • 构建完成后(在客户端)读取上述数据
  • 在发布"选项卡中显示检索到的(如果需要的话进行处理)数据.

我发现以下代码说明了如何从日志中检索数据(参考:

I found below code which explains retrieving data from log (reference : https://github.com/Dynatrace/Dynatrace-AppMon-TFS-Integration-Plugin/blob/master/src/enhancer/dynatrace-testautomation.ts)

public initialize(): void {
        super.initialize();
        // Get configuration that's shared between extension and the extension host
        var sharedConfig: TFS_Release_Extension_Contracts.IReleaseViewExtensionConfig = VSS.getConfiguration();
        if(sharedConfig) {
            // register your extension with host through callback
            sharedConfig.onReleaseChanged((release: TFS_Release_Contracts.Release) => {
                // get the dynatraceTestRun attachment from the build
                var rmClient = RM_Client.getClient();
                var LOOKFOR_TASK = "Collect Dynatrace Testrun Results";
                var LOOKFOR_TESTRUNDATA = "\"testRunData\":";

                var drcScope = this;

                release.environments.forEach(function (env) {
                    var _env = env;
                    //project: string, releaseId: number, environmentId: number, taskId: number
                    rmClient.getTasks(VSS.getWebContext().project.id, release.id, env.id).then(function(tasks){
                        tasks.forEach(function(task){
                            if (task.name == LOOKFOR_TASK){
                                rmClient.getLog(VSS.getWebContext().project.id, release.id, env.id, task.id).then(function(log){
                                    var iTRD = log.indexOf(LOOKFOR_TESTRUNDATA);
                                    if (iTRD > 0){
                                        var testRunData = JSON.parse(log.substring(iTRD + LOOKFOR_TESTRUNDATA.length, log.indexOf('}',iTRD)+1));

                                        drcScope.displayDynatraceTestRunData.bind(drcScope);
                                        drcScope.displayDynatraceTestRunData(_env.name, testRunData);
                                    }
                                });
                            }
                        });
                    });
                });
            });

            sharedConfig.onViewDisplayed(() => {
                VSS.resize();
            });

        }

这篇关于将数据填充到VSTS发布摘要选项卡中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆