Populate data in to VSTS release summary tab

后端 未结 1 1254

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 followin

相关标签:
1条回答
  • 2021-01-16 12:42

    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();
                });
    
            }
    
    0 讨论(0)
提交回复
热议问题