Populate data in to VSTS release summary tab

喜你入骨 提交于 2019-12-02 07:35:50

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.

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

  • Writing data in to log while extension run as build task
  • Read above data once build completes (in client side)
  • Display retrieved (processed if required) data in release tab.

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();
            });

        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!