diff --git a/Tasks/AppCenterDistributeV1/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AppCenterDistributeV1/Strings/resources.resjson/en-US/resources.resjson index 62f4565fa03f..b06ecc2d0491 100644 --- a/Tasks/AppCenterDistributeV1/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AppCenterDistributeV1/Strings/resources.resjson/en-US/resources.resjson @@ -1,7 +1,7 @@ { "loc.friendlyName": "App Center distribute", "loc.helpMarkDown": "For help with this task, visit the Visual Studio App Center [support site](https://aka.ms/appcentersupport/).", - "loc.description": "Distribute app builds to testers and users via App Center", + "loc.description": "Distribute app builds to testers and users via Visual Studio App Center", "loc.instanceNameFormat": "Deploy $(app) to Visual Studio App Center", "loc.releaseNotes": "Fix bug where feature branches were being truncated.", "loc.group.displayName.symbols": "Symbols", diff --git a/Tasks/AppCenterDistributeV1/Tests/L0.ts b/Tasks/AppCenterDistributeV1/Tests/L0.ts index 30161f6f827b..88f70090bc69 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0.ts @@ -85,7 +85,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: multiple dSYMs in the same foder', function () { + it('Positive path: multiple dSYMs in the same folder', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_1.js'); @@ -95,7 +95,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: multiple dSYMs in parallel foders', function () { + it('Positive path: multiple dSYMs in parallel folders', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_2.js'); @@ -186,7 +186,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: publish mandatory update)', function () { + it('Positive path: publish mandatory update', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0PublishMandatoryUpdate.js'); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0OneIpaPass.ts b/Tasks/AppCenterDistributeV1/Tests/L0OneIpaPass.ts index 8efcca5b7994..afbea708871b 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0OneIpaPass.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0OneIpaPass.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -63,13 +65,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -115,6 +110,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_1.ts b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_1.ts index 661cbbce4736..2f7b02bb21ea 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_1.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_1.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -76,13 +78,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -128,6 +123,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_2.ts b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_2.ts index 95651e0515ca..aa82d7c34b66 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_2.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_2.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -74,13 +76,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -126,6 +121,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_3.ts b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_3.ts index 5d3921293038..23a0ad9a0bea 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_3.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_3.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -74,13 +76,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -126,6 +121,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_4.ts b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_4.ts index 4401f9d988fc..7ef732c3b3c4 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_4.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0PublishCommitInfo_4.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -74,13 +76,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -126,6 +121,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0PublishMandatoryUpdate.ts b/Tasks/AppCenterDistributeV1/Tests/L0PublishMandatoryUpdate.ts index 5333c12417a7..e0a9e88439fc 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0PublishMandatoryUpdate.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0PublishMandatoryUpdate.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -75,13 +77,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -127,6 +122,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymIncludeParent.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymIncludeParent.ts index 6c6a92cc4854..dff345daaf07 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymIncludeParent.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymIncludeParent.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -65,13 +67,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -166,6 +161,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_1.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_1.ts index acd238a7844d..fcd616cc08e1 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_1.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_1.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -81,13 +83,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -202,6 +197,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_2.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_2.ts index 7a6c71cab772..1ac79a149370 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_2.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_flat_2.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -83,13 +85,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -212,6 +207,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_single.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_single.ts index a514f8ac2f1b..e9392d875863 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_single.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_single.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -79,13 +81,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -193,6 +188,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_tree.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_tree.ts index a84e3f334f0a..9e719d5e9dcc 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_tree.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymMultipleDSYMs_tree.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -87,13 +89,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -226,6 +221,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_multiple.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_multiple.ts index 43f0c385359c..7b2a57231e06 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_multiple.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_multiple.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -78,13 +80,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -190,6 +185,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_single.ts b/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_single.ts index 6d7508d6bfb3..cdb09f8a63d5 100644 --- a/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_single.ts +++ b/Tasks/AppCenterDistributeV1/Tests/L0SymPDBs_single.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -77,13 +79,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -184,6 +179,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV1/Tests/package-lock.json b/Tasks/AppCenterDistributeV1/Tests/package-lock.json index 39a39411a49b..9c7068e1f3df 100644 --- a/Tasks/AppCenterDistributeV1/Tests/package-lock.json +++ b/Tasks/AppCenterDistributeV1/Tests/package-lock.json @@ -1,6 +1,6 @@ { "name": "vsts-tasks-appcenterdistribute", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Tasks/AppCenterDistributeV1/Tests/package.json b/Tasks/AppCenterDistributeV1/Tests/package.json index 5dd9fc888d87..755534446086 100644 --- a/Tasks/AppCenterDistributeV1/Tests/package.json +++ b/Tasks/AppCenterDistributeV1/Tests/package.json @@ -1,6 +1,6 @@ { "name": "vsts-tasks-appcenterdistribute", - "version": "1.0.0", + "version": "1.1.0", "description": "Visual Studio App Center Upload Task", "main": "appcenterdistribute.js", "scripts": { diff --git a/Tasks/AppCenterDistributeV1/appcenterdistribute.ts b/Tasks/AppCenterDistributeV1/appcenterdistribute.ts index 9963f57417a9..b430159b923c 100644 --- a/Tasks/AppCenterDistributeV1/appcenterdistribute.ts +++ b/Tasks/AppCenterDistributeV1/appcenterdistribute.ts @@ -5,9 +5,11 @@ import Q = require('q'); import fs = require('fs'); import os = require('os'); +import { AzureBlobUploadHelper } from './azure-blob-upload-helper'; import { ToolRunner } from 'vsts-task-lib/toolrunner'; import utils = require('./utils'); +import { inspect } from 'util'; class UploadInfo { upload_id: string; @@ -276,27 +278,20 @@ function beginSymbolUpload(apiServer: string, apiVersion: string, appSlug: strin return defer.promise; } -function uploadSymbols(uploadUrl: string, file: string, userAgent: string): Q.Promise { +async function uploadSymbols(uploadUrl: string, file: string): Promise { tl.debug("-- Uploading symbols..."); - let defer = Q.defer(); tl.debug(`---- url: ${uploadUrl}`); - let stat = fs.statSync(file); - let headers = { - "x-ms-blob-type": "BlockBlob", - "Content-Length": stat.size, - "User-Agent": userAgent, - "internal-request-source": "VSTS" - }; + try { + const azureBlobUploadHelper = new AzureBlobUploadHelper(tl.debug); + await azureBlobUploadHelper.upload(uploadUrl, file); + } catch (e) { + tl.error(inspect(e)); - fs.createReadStream(file).pipe(request.put({ url: uploadUrl, headers: headers }, (err, res, body) => { - responseHandler(defer, err, res, body, () => { - tl.debug('-- Symbol uploaded.'); - defer.resolve(); - }); - })); + throw e; + } - return defer.promise; + tl.debug('-- Symbol uploaded.'); } function commitSymbols(apiServer: string, apiVersion: string, appSlug: string, symbol_upload_id: string, token: string, userAgent: string): Q.Promise { @@ -477,7 +472,7 @@ async function run() { let symbolsUploadInfo = await beginSymbolUpload(effectiveApiServer, effectiveApiVersion, appSlug, symbolsType, apiToken, userAgent); // upload symbols - await uploadSymbols(symbolsUploadInfo.upload_url, symbolsFile, userAgent); + await uploadSymbols(symbolsUploadInfo.upload_url, symbolsFile); // Commit the symbols upload await commitSymbols(effectiveApiServer, effectiveApiVersion, appSlug, symbolsUploadInfo.symbol_upload_id, apiToken, userAgent); diff --git a/Tasks/AppCenterDistributeV1/azure-blob-upload-helper.ts b/Tasks/AppCenterDistributeV1/azure-blob-upload-helper.ts new file mode 100644 index 000000000000..8b3f5bb56a06 --- /dev/null +++ b/Tasks/AppCenterDistributeV1/azure-blob-upload-helper.ts @@ -0,0 +1,50 @@ +import * as AzureStorage from "azure-storage"; +import * as Url from "url"; + +import { inspect } from "util"; + +export class AzureBlobUploadHelper { + constructor(private debug: Function) {} + + public async upload(uploadUrl: string, zip: string): Promise { + const urlObject = Url.parse(uploadUrl); + const blobService = this.getBlobService(urlObject); + const [container, blob] = this.getContainerAndBlob(urlObject); + + await this.uploadBlockBlob(blobService, container, blob, zip); + } + + private uploadBlockBlob(blobService: AzureStorage.BlobService, container: string, blob: string, file: string): Promise { + return new Promise ((resolve, reject) => { + blobService.createBlockBlobFromLocalFile(container, blob, file, { + contentSettings: { + contentType: "application/zip" + } + }, (error, result, response) => { + if (error) { + this.debug(`Failed to upload ZIP with symbols - ${inspect(error)}`); + reject(new Error("failed to upload ZIP with symbols")); + } else { + resolve(); + } + }); + }); + } + + private getBlobService(urlObject: Url.Url): AzureStorage.BlobService { + const blobEndpoint = Url.format({ + protocol: urlObject.protocol, + host: urlObject.host + }); + const sharedAccessSignature = urlObject.query as string; + + const connectionString = "BlobEndpoint=" + blobEndpoint + ";" + "SharedAccessSignature=" + sharedAccessSignature; + + return new AzureStorage.BlobService(connectionString); + } + + private getContainerAndBlob(urlObject: Url.Url): [string, string] { + const splitPathName = urlObject.pathname.split("/"); + return [splitPathName[1], splitPathName[2]]; + } +} \ No newline at end of file diff --git a/Tasks/AppCenterDistributeV1/package-lock.json b/Tasks/AppCenterDistributeV1/package-lock.json index 720d6613e120..244eded8ba47 100644 --- a/Tasks/AppCenterDistributeV1/package-lock.json +++ b/Tasks/AppCenterDistributeV1/package-lock.json @@ -40,6 +40,31 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, + "azure-storage": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/azure-storage/-/azure-storage-2.10.3.tgz", + "integrity": "sha512-IGLs5Xj6kO8Ii90KerQrrwuJKexLgSwYC4oLWmc11mzKe7Jt2E5IVg+ZQ8K53YWZACtVTMBNO3iGuA+4ipjJxQ==", + "requires": { + "browserify-mime": "~1.2.9", + "extend": "^3.0.2", + "json-edm-parser": "0.1.2", + "md5.js": "1.3.4", + "readable-stream": "~2.0.0", + "request": "^2.86.0", + "underscore": "~1.8.3", + "uuid": "^3.0.0", + "validator": "~9.4.1", + "xml2js": "0.2.8", + "xmlbuilder": "^9.0.7" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -63,6 +88,11 @@ "concat-map": "0.0.1" } }, + "browserify-mime": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/browserify-mime/-/browserify-mime-1.2.9.tgz", + "integrity": "sha1-rrGvKN5sDXpqLOQK22j/GEIq8x8=" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -180,6 +210,15 @@ "har-schema": "^2.0.0" } }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -221,6 +260,14 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "optional": true }, + "json-edm-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/json-edm-parser/-/json-edm-parser-0.1.2.tgz", + "integrity": "sha1-HmCw/vG8CvZ7wNFG393lSGzWFbQ=", + "requires": { + "jsonparse": "~1.2.0" + } + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -236,6 +283,11 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "jsonparse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.2.0.tgz", + "integrity": "sha1-XAxWhRBxYOcv50ib3eoLRMK8Z70=" + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -267,6 +319,15 @@ "immediate": "~3.0.5" } }, + "md5.js": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", + "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", @@ -373,6 +434,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "sax": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz", + "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=" + }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -425,6 +491,11 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "optional": true }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -435,6 +506,11 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" }, + "validator": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.4.1.tgz", + "integrity": "sha512-YV5KjzvRmSyJ1ee/Dm5UED0G+1L4GZnLN3w6/T+zZm8scVua4sOhYKWTUrKa0H/tMiJyO9QLHMPN+9mB/aMunA==" + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -464,6 +540,19 @@ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" } } + }, + "xml2js": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz", + "integrity": "sha1-m4FpCTFjH/CdGVdUn69U9PmAs8I=", + "requires": { + "sax": "0.5.x" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" } } } diff --git a/Tasks/AppCenterDistributeV1/package.json b/Tasks/AppCenterDistributeV1/package.json index 296bf0d99a59..0ab0adf20060 100644 --- a/Tasks/AppCenterDistributeV1/package.json +++ b/Tasks/AppCenterDistributeV1/package.json @@ -17,8 +17,9 @@ }, "homepage": "https://github.com/Microsoft/azure-pipelines-tasks", "dependencies": { - "vsts-task-lib": "2.0.5", + "azure-storage": "^2.10.3", "jszip": "^3.1.2", - "request": "2.87.0" + "request": "2.87.0", + "vsts-task-lib": "2.0.5" } } diff --git a/Tasks/AppCenterDistributeV1/task.json b/Tasks/AppCenterDistributeV1/task.json index 0161a1335199..48b86c676a6b 100644 --- a/Tasks/AppCenterDistributeV1/task.json +++ b/Tasks/AppCenterDistributeV1/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 151, + "Minor": 152, "Patch": 1 }, "releaseNotes": "Fix bug where feature branches were being truncated.", diff --git a/Tasks/AppCenterDistributeV1/task.loc.json b/Tasks/AppCenterDistributeV1/task.loc.json index 02ec1dc2e160..b7ce4470b3d2 100644 --- a/Tasks/AppCenterDistributeV1/task.loc.json +++ b/Tasks/AppCenterDistributeV1/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 151, + "Minor": 152, "Patch": 1 }, "releaseNotes": "ms-resource:loc.releaseNotes", diff --git a/Tasks/AppCenterDistributeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AppCenterDistributeV2/Strings/resources.resjson/en-US/resources.resjson index 827efef02676..9c3ec1f83437 100644 --- a/Tasks/AppCenterDistributeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AppCenterDistributeV2/Strings/resources.resjson/en-US/resources.resjson @@ -1,7 +1,7 @@ { "loc.friendlyName": "App Center distribute", "loc.helpMarkDown": "For help with this task, visit the Visual Studio App Center [support site](https://aka.ms/appcentersupport/).", - "loc.description": "Distribute app builds to testers and users via App Center", + "loc.description": "Distribute app builds to testers and users via Visual Studio App Center", "loc.instanceNameFormat": "Deploy $(app) to Visual Studio App Center", "loc.releaseNotes": "Added support for multiple destinations.", "loc.group.displayName.symbols": "Symbols", diff --git a/Tasks/AppCenterDistributeV2/Tests/L0.ts b/Tasks/AppCenterDistributeV2/Tests/L0.ts index 21e890d718f7..0149abcd0a76 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0.ts @@ -85,7 +85,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: multiple dSYMs in the same foder', function () { + it('Positive path: multiple dSYMs in the same folder', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_1.js'); @@ -95,7 +95,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: multiple dSYMs in parallel foders', function () { + it('Positive path: multiple dSYMs in parallel folders', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_2.js'); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0OneIpaPass.ts b/Tasks/AppCenterDistributeV2/Tests/L0OneIpaPass.ts index 8efcca5b7994..afbea708871b 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0OneIpaPass.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0OneIpaPass.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -63,13 +65,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -115,6 +110,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_1.ts b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_1.ts index 661cbbce4736..2f7b02bb21ea 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_1.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_1.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -76,13 +78,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -128,6 +123,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_2.ts b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_2.ts index 95651e0515ca..aa82d7c34b66 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_2.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_2.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -74,13 +76,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -126,6 +121,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_3.ts b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_3.ts index 5d3921293038..23a0ad9a0bea 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_3.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_3.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -74,13 +76,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -126,6 +121,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_4.ts b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_4.ts index 4401f9d988fc..7ef732c3b3c4 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_4.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0PublishCommitInfo_4.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -74,13 +76,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -126,6 +121,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0PublishMandatoryUpdate.ts b/Tasks/AppCenterDistributeV2/Tests/L0PublishMandatoryUpdate.ts index 5333c12417a7..e0a9e88439fc 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0PublishMandatoryUpdate.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0PublishMandatoryUpdate.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -75,13 +77,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -127,6 +122,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0PublishMultipleDestinations.ts b/Tasks/AppCenterDistributeV2/Tests/L0PublishMultipleDestinations.ts index 40f70e4aebae..f9af41c1dfc4 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0PublishMultipleDestinations.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0PublishMultipleDestinations.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -79,13 +81,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -131,6 +126,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymIncludeParent.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymIncludeParent.ts index 6c6a92cc4854..dff345daaf07 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymIncludeParent.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymIncludeParent.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -65,13 +67,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -166,6 +161,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_1.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_1.ts index acd238a7844d..fcd616cc08e1 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_1.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_1.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -81,13 +83,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -202,6 +197,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_2.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_2.ts index 7a6c71cab772..1ac79a149370 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_2.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_flat_2.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -83,13 +85,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -212,6 +207,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_single.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_single.ts index a514f8ac2f1b..e9392d875863 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_single.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_single.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -79,13 +81,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -193,6 +188,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_tree.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_tree.ts index a84e3f334f0a..9e719d5e9dcc 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_tree.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymMultipleDSYMs_tree.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -87,13 +89,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -226,6 +221,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_multiple.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_multiple.ts index 43f0c385359c..7b2a57231e06 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_multiple.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_multiple.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -78,13 +80,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -190,6 +185,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_single.ts b/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_single.ts index 6d7508d6bfb3..cdb09f8a63d5 100644 --- a/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_single.ts +++ b/Tasks/AppCenterDistributeV2/Tests/L0SymPDBs_single.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -77,13 +79,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -184,6 +179,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV2/Tests/package-lock.json b/Tasks/AppCenterDistributeV2/Tests/package-lock.json index 39a39411a49b..9c7068e1f3df 100644 --- a/Tasks/AppCenterDistributeV2/Tests/package-lock.json +++ b/Tasks/AppCenterDistributeV2/Tests/package-lock.json @@ -1,6 +1,6 @@ { "name": "vsts-tasks-appcenterdistribute", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Tasks/AppCenterDistributeV2/Tests/package.json b/Tasks/AppCenterDistributeV2/Tests/package.json index 5dd9fc888d87..755534446086 100644 --- a/Tasks/AppCenterDistributeV2/Tests/package.json +++ b/Tasks/AppCenterDistributeV2/Tests/package.json @@ -1,6 +1,6 @@ { "name": "vsts-tasks-appcenterdistribute", - "version": "1.0.0", + "version": "1.1.0", "description": "Visual Studio App Center Upload Task", "main": "appcenterdistribute.js", "scripts": { diff --git a/Tasks/AppCenterDistributeV2/appcenterdistribute.ts b/Tasks/AppCenterDistributeV2/appcenterdistribute.ts index fbd814c6c6e4..06cac4f6d90d 100644 --- a/Tasks/AppCenterDistributeV2/appcenterdistribute.ts +++ b/Tasks/AppCenterDistributeV2/appcenterdistribute.ts @@ -8,6 +8,8 @@ import os = require('os'); import { ToolRunner } from 'vsts-task-lib/toolrunner'; import utils = require('./utils'); +import { AzureBlobUploadHelper } from './azure-blob-upload-helper'; +import { inspect } from 'util'; class UploadInfo { upload_id: string; @@ -272,27 +274,20 @@ function beginSymbolUpload(apiServer: string, apiVersion: string, appSlug: strin return defer.promise; } -function uploadSymbols(uploadUrl: string, file: string, userAgent: string): Q.Promise { +async function uploadSymbols(uploadUrl: string, file: string): Promise { tl.debug("-- Uploading symbols..."); - let defer = Q.defer(); tl.debug(`---- url: ${uploadUrl}`); - let stat = fs.statSync(file); - let headers = { - "x-ms-blob-type": "BlockBlob", - "Content-Length": stat.size, - "User-Agent": userAgent, - "internal-request-source": "VSTS" - }; + try { + const azureBlobUploadHelper = new AzureBlobUploadHelper(tl.debug); + await azureBlobUploadHelper.upload(uploadUrl, file); + } catch (e) { + tl.error(inspect(e)); - fs.createReadStream(file).pipe(request.put({ url: uploadUrl, headers: headers }, (err, res, body) => { - responseHandler(defer, err, res, body, () => { - tl.debug('-- Symbol uploaded.'); - defer.resolve(); - }); - })); + throw e; + } - return defer.promise; + tl.debug('-- Symbol uploaded.'); } function commitSymbols(apiServer: string, apiVersion: string, appSlug: string, symbol_upload_id: string, token: string, userAgent: string): Q.Promise { @@ -477,7 +472,7 @@ async function run() { let symbolsUploadInfo = await beginSymbolUpload(effectiveApiServer, effectiveApiVersion, appSlug, symbolsType, apiToken, userAgent); // upload symbols - await uploadSymbols(symbolsUploadInfo.upload_url, symbolsFile, userAgent); + await uploadSymbols(symbolsUploadInfo.upload_url, symbolsFile); // Commit the symbols upload await commitSymbols(effectiveApiServer, effectiveApiVersion, appSlug, symbolsUploadInfo.symbol_upload_id, apiToken, userAgent); diff --git a/Tasks/AppCenterDistributeV2/azure-blob-upload-helper.ts b/Tasks/AppCenterDistributeV2/azure-blob-upload-helper.ts new file mode 100644 index 000000000000..8b3f5bb56a06 --- /dev/null +++ b/Tasks/AppCenterDistributeV2/azure-blob-upload-helper.ts @@ -0,0 +1,50 @@ +import * as AzureStorage from "azure-storage"; +import * as Url from "url"; + +import { inspect } from "util"; + +export class AzureBlobUploadHelper { + constructor(private debug: Function) {} + + public async upload(uploadUrl: string, zip: string): Promise { + const urlObject = Url.parse(uploadUrl); + const blobService = this.getBlobService(urlObject); + const [container, blob] = this.getContainerAndBlob(urlObject); + + await this.uploadBlockBlob(blobService, container, blob, zip); + } + + private uploadBlockBlob(blobService: AzureStorage.BlobService, container: string, blob: string, file: string): Promise { + return new Promise ((resolve, reject) => { + blobService.createBlockBlobFromLocalFile(container, blob, file, { + contentSettings: { + contentType: "application/zip" + } + }, (error, result, response) => { + if (error) { + this.debug(`Failed to upload ZIP with symbols - ${inspect(error)}`); + reject(new Error("failed to upload ZIP with symbols")); + } else { + resolve(); + } + }); + }); + } + + private getBlobService(urlObject: Url.Url): AzureStorage.BlobService { + const blobEndpoint = Url.format({ + protocol: urlObject.protocol, + host: urlObject.host + }); + const sharedAccessSignature = urlObject.query as string; + + const connectionString = "BlobEndpoint=" + blobEndpoint + ";" + "SharedAccessSignature=" + sharedAccessSignature; + + return new AzureStorage.BlobService(connectionString); + } + + private getContainerAndBlob(urlObject: Url.Url): [string, string] { + const splitPathName = urlObject.pathname.split("/"); + return [splitPathName[1], splitPathName[2]]; + } +} \ No newline at end of file diff --git a/Tasks/AppCenterDistributeV2/package-lock.json b/Tasks/AppCenterDistributeV2/package-lock.json index 720d6613e120..244eded8ba47 100644 --- a/Tasks/AppCenterDistributeV2/package-lock.json +++ b/Tasks/AppCenterDistributeV2/package-lock.json @@ -40,6 +40,31 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, + "azure-storage": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/azure-storage/-/azure-storage-2.10.3.tgz", + "integrity": "sha512-IGLs5Xj6kO8Ii90KerQrrwuJKexLgSwYC4oLWmc11mzKe7Jt2E5IVg+ZQ8K53YWZACtVTMBNO3iGuA+4ipjJxQ==", + "requires": { + "browserify-mime": "~1.2.9", + "extend": "^3.0.2", + "json-edm-parser": "0.1.2", + "md5.js": "1.3.4", + "readable-stream": "~2.0.0", + "request": "^2.86.0", + "underscore": "~1.8.3", + "uuid": "^3.0.0", + "validator": "~9.4.1", + "xml2js": "0.2.8", + "xmlbuilder": "^9.0.7" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -63,6 +88,11 @@ "concat-map": "0.0.1" } }, + "browserify-mime": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/browserify-mime/-/browserify-mime-1.2.9.tgz", + "integrity": "sha1-rrGvKN5sDXpqLOQK22j/GEIq8x8=" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -180,6 +210,15 @@ "har-schema": "^2.0.0" } }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -221,6 +260,14 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "optional": true }, + "json-edm-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/json-edm-parser/-/json-edm-parser-0.1.2.tgz", + "integrity": "sha1-HmCw/vG8CvZ7wNFG393lSGzWFbQ=", + "requires": { + "jsonparse": "~1.2.0" + } + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -236,6 +283,11 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "jsonparse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.2.0.tgz", + "integrity": "sha1-XAxWhRBxYOcv50ib3eoLRMK8Z70=" + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -267,6 +319,15 @@ "immediate": "~3.0.5" } }, + "md5.js": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", + "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", @@ -373,6 +434,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "sax": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz", + "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=" + }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -425,6 +491,11 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "optional": true }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -435,6 +506,11 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" }, + "validator": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.4.1.tgz", + "integrity": "sha512-YV5KjzvRmSyJ1ee/Dm5UED0G+1L4GZnLN3w6/T+zZm8scVua4sOhYKWTUrKa0H/tMiJyO9QLHMPN+9mB/aMunA==" + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -464,6 +540,19 @@ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" } } + }, + "xml2js": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz", + "integrity": "sha1-m4FpCTFjH/CdGVdUn69U9PmAs8I=", + "requires": { + "sax": "0.5.x" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" } } } diff --git a/Tasks/AppCenterDistributeV2/package.json b/Tasks/AppCenterDistributeV2/package.json index 296bf0d99a59..0ab0adf20060 100644 --- a/Tasks/AppCenterDistributeV2/package.json +++ b/Tasks/AppCenterDistributeV2/package.json @@ -17,8 +17,9 @@ }, "homepage": "https://github.com/Microsoft/azure-pipelines-tasks", "dependencies": { - "vsts-task-lib": "2.0.5", + "azure-storage": "^2.10.3", "jszip": "^3.1.2", - "request": "2.87.0" + "request": "2.87.0", + "vsts-task-lib": "2.0.5" } } diff --git a/Tasks/AppCenterDistributeV2/task.json b/Tasks/AppCenterDistributeV2/task.json index 488f786fd817..c9fe3e961efc 100644 --- a/Tasks/AppCenterDistributeV2/task.json +++ b/Tasks/AppCenterDistributeV2/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 151, + "Minor": 152, "Patch": 1 }, "releaseNotes": "Added support for multiple destinations.", diff --git a/Tasks/AppCenterDistributeV2/task.loc.json b/Tasks/AppCenterDistributeV2/task.loc.json index f0e3fcc51a9a..f21fad1ddcf8 100644 --- a/Tasks/AppCenterDistributeV2/task.loc.json +++ b/Tasks/AppCenterDistributeV2/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 151, + "Minor": 152, "Patch": 1 }, "releaseNotes": "ms-resource:loc.releaseNotes", diff --git a/Tasks/AppCenterDistributeV3/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AppCenterDistributeV3/Strings/resources.resjson/en-US/resources.resjson index c18ee3fa6b9b..e46988172dba 100644 --- a/Tasks/AppCenterDistributeV3/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AppCenterDistributeV3/Strings/resources.resjson/en-US/resources.resjson @@ -1,7 +1,7 @@ { "loc.friendlyName": "App Center distribute", "loc.helpMarkDown": "For help with this task, visit the Visual Studio App Center [support site](https://aka.ms/appcentersupport/).", - "loc.description": "Distribute app builds to testers and users via App Center", + "loc.description": "Distribute app builds to testers and users via Visual Studio App Center", "loc.instanceNameFormat": "Deploy $(app) to Visual Studio App Center", "loc.releaseNotes": "Added support for multiple destinations.", "loc.group.displayName.symbols": "Symbols", diff --git a/Tasks/AppCenterDistributeV3/Tests/L0.ts b/Tasks/AppCenterDistributeV3/Tests/L0.ts index b6f88d2863df..cf7528b02f9c 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0.ts @@ -131,7 +131,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: multiple dSYMs in the same foder', function () { + it('Positive path: multiple dSYMs in the same folder', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_1.js'); @@ -141,7 +141,7 @@ describe('AppCenterDistribute L0 Suite', function () { assert(tr.succeeded, 'task should have succeeded'); }); - it('Positive path: multiple dSYMs in parallel foders', function () { + it('Positive path: multiple dSYMs in parallel folders', function () { this.timeout(4000); let tp = path.join(__dirname, 'L0SymMultipleDSYMs_flat_2.js'); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0NoSymbolsFails.ts b/Tasks/AppCenterDistributeV3/Tests/L0NoSymbolsFails.ts index 3a7e5d6a3483..1bd72c195a66 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0NoSymbolsFails.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0NoSymbolsFails.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var nock = require('nock'); @@ -35,6 +37,13 @@ let a: ma.TaskLibAnswers = { "/test/path/to/symbols.dSYM": false } }; + + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.setAnswers(a); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0OneIpaPass.ts b/Tasks/AppCenterDistributeV3/Tests/L0OneIpaPass.ts index 9cac0061be92..25b82ece6177 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0OneIpaPass.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0OneIpaPass.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -68,13 +70,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -120,6 +115,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_1.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_1.ts index 1f494f0a976f..e70acb5078bb 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_1.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_1.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -81,13 +83,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -133,6 +128,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_2.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_2.ts index f0aeacfddbdc..c2a784d283a2 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_2.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_2.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -79,13 +81,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -131,6 +126,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_3.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_3.ts index bb6772338097..b672754370fc 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_3.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_3.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -79,13 +81,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -131,6 +126,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_4.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_4.ts index e6e5ebc07595..06b3b3120be1 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_4.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishCommitInfo_4.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -79,13 +81,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -131,6 +126,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishMandatoryUpdate.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishMandatoryUpdate.ts index 46bb29750757..921f7bab4ff2 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishMandatoryUpdate.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishMandatoryUpdate.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -80,13 +82,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -132,6 +127,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishMultipleDestinations.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishMultipleDestinations.ts index 9abd1820ec85..71878e096045 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishMultipleDestinations.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishMultipleDestinations.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -84,13 +86,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -136,6 +131,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishSilentUpdate.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishSilentUpdate.ts index 1e33a5979f14..c5679579436c 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishSilentUpdate.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishSilentUpdate.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Stats = require('fs').Stats @@ -82,13 +84,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { @@ -134,6 +129,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishStore.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishStore.ts index a751bfd1314e..e40a46177d2f 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishStore.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishStore.ts @@ -70,13 +70,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { diff --git a/Tasks/AppCenterDistributeV3/Tests/L0PublishStoreIgnoreSilent.ts b/Tasks/AppCenterDistributeV3/Tests/L0PublishStoreIgnoreSilent.ts index 4e57c8ef1b61..106d6c8a4b14 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0PublishStoreIgnoreSilent.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0PublishStoreIgnoreSilent.ts @@ -71,13 +71,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch("/v0.1/apps/testuser/testapp/symbol_uploads/100", { diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymIncludeParent.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymIncludeParent.ts index b03c593a6425..393fb1ed195a 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymIncludeParent.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymIncludeParent.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -70,13 +72,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -171,6 +166,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_1.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_1.ts index a6fe8ab373ea..ca2cdfe201c0 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_1.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_1.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -86,13 +88,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -207,6 +202,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_2.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_2.ts index 7d3aab5073e1..40f2bfb45154 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_2.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_flat_2.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -88,13 +90,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -217,6 +212,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_single.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_single.ts index ae53b04410c6..3fa0136559b5 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_single.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_single.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -84,13 +86,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -198,6 +193,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_tree.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_tree.ts index e999ce18113e..cc7e72ad1cf3 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_tree.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymMultipleDSYMs_tree.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -92,13 +94,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -231,6 +226,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_multiple.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_multiple.ts index 92783e2eefe8..1abb09f2a6d7 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_multiple.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_multiple.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -83,13 +85,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -195,6 +190,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_single.ts b/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_single.ts index e483e1345b7f..f02d1dbdff6b 100644 --- a/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_single.ts +++ b/Tasks/AppCenterDistributeV3/Tests/L0SymPDBs_single.ts @@ -3,6 +3,8 @@ import ma = require('vsts-task-lib/mock-answer'); import tmrm = require('vsts-task-lib/mock-run'); import path = require('path'); import fs = require('fs'); +import azureBlobUploadHelper = require('../azure-blob-upload-helper'); + var Readable = require('stream').Readable var Writable = require('stream').Writable var Stats = require('fs').Stats @@ -82,13 +84,6 @@ nock('https://example.test') expiration_date: 1234567 }); -//upload symbols -nock('https://example.upload.test') - .put('/symbol_upload') - .reply(201, { - status: 'success' - }); - //finishing symbol upload, commit the symbol nock('https://example.test') .patch('/v0.1/apps/testuser/testapp/symbol_uploads/100', { @@ -189,6 +184,12 @@ fs.statSync = (s: string) => { return stat; } + +azureBlobUploadHelper.AzureBlobUploadHelper.prototype.upload = async () => { + return Promise.resolve(); +} + +tmr.registerMock('azure-blob-upload-helper', azureBlobUploadHelper); tmr.registerMock('fs', fs); tmr.run(); diff --git a/Tasks/AppCenterDistributeV3/appcenterdistribute.ts b/Tasks/AppCenterDistributeV3/appcenterdistribute.ts index b47a39574499..89b79216affe 100644 --- a/Tasks/AppCenterDistributeV3/appcenterdistribute.ts +++ b/Tasks/AppCenterDistributeV3/appcenterdistribute.ts @@ -5,9 +5,11 @@ import Q = require('q'); import fs = require('fs'); import os = require('os'); +import { AzureBlobUploadHelper } from './azure-blob-upload-helper'; import { ToolRunner } from 'vsts-task-lib/toolrunner'; import utils = require('./utils'); +import { inspect } from 'util'; class UploadInfo { upload_id: string; @@ -317,27 +319,20 @@ function beginSymbolUpload(apiServer: string, apiVersion: string, appSlug: strin return defer.promise; } -function uploadSymbols(uploadUrl: string, file: string, userAgent: string): Q.Promise { +async function uploadSymbols(uploadUrl: string, file: string): Promise { tl.debug("-- Uploading symbols..."); - let defer = Q.defer(); tl.debug(`---- url: ${uploadUrl}`); - let stat = fs.statSync(file); - let headers = { - "x-ms-blob-type": "BlockBlob", - "Content-Length": stat.size, - "User-Agent": userAgent, - "internal-request-source": "VSTS" - }; + try { + const azureBlobUploadHelper = new AzureBlobUploadHelper(tl.debug); + await azureBlobUploadHelper.upload(uploadUrl, file); + } catch (e) { + tl.error(inspect(e)); - fs.createReadStream(file).pipe(request.put({ url: uploadUrl, headers: headers }, (err, res, body) => { - responseHandler(defer, err, res, body, () => { - tl.debug('-- Symbol uploaded.'); - defer.resolve(); - }); - })); + throw e; + } - return defer.promise; + tl.debug('-- Symbol uploaded.'); } function commitSymbols(apiServer: string, apiVersion: string, appSlug: string, symbol_upload_id: string, token: string, userAgent: string): Q.Promise { @@ -534,7 +529,7 @@ async function run() { let symbolsUploadInfo = await beginSymbolUpload(effectiveApiServer, effectiveApiVersion, appSlug, symbolsType, apiToken, userAgent); // upload symbols - await uploadSymbols(symbolsUploadInfo.upload_url, symbolsFile, userAgent); + await uploadSymbols(symbolsUploadInfo.upload_url, symbolsFile); // Commit the symbols upload await commitSymbols(effectiveApiServer, effectiveApiVersion, appSlug, symbolsUploadInfo.symbol_upload_id, apiToken, userAgent); diff --git a/Tasks/AppCenterDistributeV3/azure-blob-upload-helper.ts b/Tasks/AppCenterDistributeV3/azure-blob-upload-helper.ts new file mode 100644 index 000000000000..8b3f5bb56a06 --- /dev/null +++ b/Tasks/AppCenterDistributeV3/azure-blob-upload-helper.ts @@ -0,0 +1,50 @@ +import * as AzureStorage from "azure-storage"; +import * as Url from "url"; + +import { inspect } from "util"; + +export class AzureBlobUploadHelper { + constructor(private debug: Function) {} + + public async upload(uploadUrl: string, zip: string): Promise { + const urlObject = Url.parse(uploadUrl); + const blobService = this.getBlobService(urlObject); + const [container, blob] = this.getContainerAndBlob(urlObject); + + await this.uploadBlockBlob(blobService, container, blob, zip); + } + + private uploadBlockBlob(blobService: AzureStorage.BlobService, container: string, blob: string, file: string): Promise { + return new Promise ((resolve, reject) => { + blobService.createBlockBlobFromLocalFile(container, blob, file, { + contentSettings: { + contentType: "application/zip" + } + }, (error, result, response) => { + if (error) { + this.debug(`Failed to upload ZIP with symbols - ${inspect(error)}`); + reject(new Error("failed to upload ZIP with symbols")); + } else { + resolve(); + } + }); + }); + } + + private getBlobService(urlObject: Url.Url): AzureStorage.BlobService { + const blobEndpoint = Url.format({ + protocol: urlObject.protocol, + host: urlObject.host + }); + const sharedAccessSignature = urlObject.query as string; + + const connectionString = "BlobEndpoint=" + blobEndpoint + ";" + "SharedAccessSignature=" + sharedAccessSignature; + + return new AzureStorage.BlobService(connectionString); + } + + private getContainerAndBlob(urlObject: Url.Url): [string, string] { + const splitPathName = urlObject.pathname.split("/"); + return [splitPathName[1], splitPathName[2]]; + } +} \ No newline at end of file diff --git a/Tasks/AppCenterDistributeV3/package-lock.json b/Tasks/AppCenterDistributeV3/package-lock.json index 720d6613e120..244eded8ba47 100644 --- a/Tasks/AppCenterDistributeV3/package-lock.json +++ b/Tasks/AppCenterDistributeV3/package-lock.json @@ -40,6 +40,31 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, + "azure-storage": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/azure-storage/-/azure-storage-2.10.3.tgz", + "integrity": "sha512-IGLs5Xj6kO8Ii90KerQrrwuJKexLgSwYC4oLWmc11mzKe7Jt2E5IVg+ZQ8K53YWZACtVTMBNO3iGuA+4ipjJxQ==", + "requires": { + "browserify-mime": "~1.2.9", + "extend": "^3.0.2", + "json-edm-parser": "0.1.2", + "md5.js": "1.3.4", + "readable-stream": "~2.0.0", + "request": "^2.86.0", + "underscore": "~1.8.3", + "uuid": "^3.0.0", + "validator": "~9.4.1", + "xml2js": "0.2.8", + "xmlbuilder": "^9.0.7" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -63,6 +88,11 @@ "concat-map": "0.0.1" } }, + "browserify-mime": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/browserify-mime/-/browserify-mime-1.2.9.tgz", + "integrity": "sha1-rrGvKN5sDXpqLOQK22j/GEIq8x8=" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -180,6 +210,15 @@ "har-schema": "^2.0.0" } }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -221,6 +260,14 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "optional": true }, + "json-edm-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/json-edm-parser/-/json-edm-parser-0.1.2.tgz", + "integrity": "sha1-HmCw/vG8CvZ7wNFG393lSGzWFbQ=", + "requires": { + "jsonparse": "~1.2.0" + } + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -236,6 +283,11 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "jsonparse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.2.0.tgz", + "integrity": "sha1-XAxWhRBxYOcv50ib3eoLRMK8Z70=" + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -267,6 +319,15 @@ "immediate": "~3.0.5" } }, + "md5.js": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", + "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", @@ -373,6 +434,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "sax": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz", + "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=" + }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -425,6 +491,11 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "optional": true }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -435,6 +506,11 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" }, + "validator": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.4.1.tgz", + "integrity": "sha512-YV5KjzvRmSyJ1ee/Dm5UED0G+1L4GZnLN3w6/T+zZm8scVua4sOhYKWTUrKa0H/tMiJyO9QLHMPN+9mB/aMunA==" + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -464,6 +540,19 @@ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" } } + }, + "xml2js": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz", + "integrity": "sha1-m4FpCTFjH/CdGVdUn69U9PmAs8I=", + "requires": { + "sax": "0.5.x" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" } } } diff --git a/Tasks/AppCenterDistributeV3/package.json b/Tasks/AppCenterDistributeV3/package.json index 296bf0d99a59..0ab0adf20060 100644 --- a/Tasks/AppCenterDistributeV3/package.json +++ b/Tasks/AppCenterDistributeV3/package.json @@ -17,8 +17,9 @@ }, "homepage": "https://github.com/Microsoft/azure-pipelines-tasks", "dependencies": { - "vsts-task-lib": "2.0.5", + "azure-storage": "^2.10.3", "jszip": "^3.1.2", - "request": "2.87.0" + "request": "2.87.0", + "vsts-task-lib": "2.0.5" } } diff --git a/Tasks/AppCenterDistributeV3/task.json b/Tasks/AppCenterDistributeV3/task.json index 307734b4074b..24b0c87b6da0 100644 --- a/Tasks/AppCenterDistributeV3/task.json +++ b/Tasks/AppCenterDistributeV3/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 151, + "Minor": 152, "Patch": 1 }, "releaseNotes": "Added support for multiple destinations.", diff --git a/Tasks/AppCenterDistributeV3/task.loc.json b/Tasks/AppCenterDistributeV3/task.loc.json index 5d5b401f593a..1f8f27cf6b90 100644 --- a/Tasks/AppCenterDistributeV3/task.loc.json +++ b/Tasks/AppCenterDistributeV3/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 151, + "Minor": 152, "Patch": 1 }, "releaseNotes": "ms-resource:loc.releaseNotes",