Я приложил мои данные сборки задачи с помощью ведения журнала команд
https://github.com/Microsoft/vsts-tasks/blob/986f8f5112017474962affe58c9ebaf394fb9354/docs/authoring/commands.md
//Build Task
class TestClass {
_name: string;
_age: number;
constructor(name: string, age:number) {
this._name = name;
this._age = age;
}
}
var data = new TestClass(TinTin,100);
//Create a folder
tl.mkdirP("c:/myfolder/");
//Write data to a file
tl.writeFile("c:/myfolder/mydata.txt",JSON.stringify(data));
//Executes command to attach the file to build
console.log("##vso[task.addattachment type=myAttachmentType;name=myAttachmentName;]c:/myfolder/mydata.txt");
Получить вложение из сводной страницы.
https://github.com/Microsoft/vsts-extension-samples/blob/master/build-results-enhancer/src/enhancer/tab.ts
//Summary Page
/// <reference path="../definitions/Q.d.ts" />
/// <reference path="../definitions/vss.d.ts" />
/// <reference path="../definitions/tfs.d.ts" />
/// <reference path="../definitions/jquery.d.ts" />
import VSS_Service = require("VSS/Service");
import Controls = require("VSS/Controls");
import TFS_Build_Contracts = require("TFS/Build/Contracts");
import TFS_Build_Extension_Contracts = require("TFS/Build/ExtensionContracts");
import DT_Client = require("TFS/DistributedTask/TaskRestClient");
export class StatusSection extends Controls.BaseControl { \t
\t constructor() {
\t \t super();
\t }
\t \t
\t public initialize(): void {
\t \t super.initialize();
\t \t // Get configuration that's shared between extension and the extension host
\t \t var sharedConfig: TFS_Build_Extension_Contracts.IBuildResultsViewExtensionConfig = VSS.getConfiguration();
\t \t var vsoContext = VSS.getWebContext();
\t \t
\t \t if(sharedConfig) {
\t \t \t // register your extension with host through callback
\t \t \t sharedConfig.onBuildChanged((build: TFS_Build_Contracts.Build) => {
\t \t \t \t var taskClient = DT_Client.getClient();
\t \t \t \t taskClient.getPlanAttachments(vsoContext.project.id, "build", build.orchestrationPlan.planId, "myAttachmentType").then((taskAttachments)=> {
\t \t \t \t \t \t \t \t \t \t \t
\t \t \t \t if (taskAttachments.length === 1) {
\t \t \t \t \t var recId = taskAttachments[0].recordId;
\t \t \t \t \t var timelineId = taskAttachments[0].timelineId;
\t \t \t \t \t taskClient.getAttachmentContent(vsoContext.project.id, "build", build.orchestrationPlan.planId,timelineId,recId,"myAttachmentType","myAttachmentName").then((attachementContent)=> { \t \t \t \t \t \t \t \t \t \t \t \t \t \t
\t \t \t \t \t \t function arrayBufferToString(buffer){
\t \t \t \t \t \t \t \t \t var arr = new Uint8Array(buffer);
\t \t \t \t \t \t \t \t \t var str = String.fromCharCode.apply(String, arr);
\t \t \t \t \t \t \t \t \t if(/[\u0080-\uffff]/.test(str)){
\t \t \t \t \t \t \t \t \t \t throw new Error("this string seems to contain (still encoded) multibytes");
\t \t \t \t \t \t \t \t \t }
\t \t \t \t \t \t \t \t \t return str;
\t \t \t \t \t \t \t \t }
\t \t \t \t \t \t
\t \t \t \t \t \t var summaryPageData = arrayBufferToString(attachementContent);
\t \t \t \t \t \t
\t \t \t \t \t \t //Deserialize data
\t \t \t \t \t \t var ob = JSON.parse(summaryPageData);
\t \t \t \t \t \t console.log("Name: " + ob._name);
\t \t \t \t \t \t console.log("Age: " + ob._age);
\t \t \t \t \t }); \t \t \t \t \t
\t \t \t \t }
\t \t \t \t }); \t
\t \t \t });
\t \t } \t \t
\t } \t
}
StatusSection.enhance(StatusSection, $(".build-status"), {});
// Notify the parent frame that the host has been loaded
VSS.notifyLoadSucceeded();
Не могли бы вы назвать веб-сервис, когда сборка завершена? Основываясь на этом примере https://github.com/Microsoft/vsts-extension-samples/tree/master/build-results-enhancer, он обновляет изображение при завершении сборки. –
Мне нужно передать некоторые данные на итоговую страницу, я планирую использовать VSS Extension Data Service для этого. 1.) Ill Сохранить результат из задачи сборки в качестве параметра в службе данных расширения. 2.) Я прочитал настройку из службы данных расширений на странице загрузки резюме и привязал эти значения к html. Я предполагаю, что это правильно. Thanks- – Bandara