From 8994bb8713cb6105334d68bc7b15f63951ea52da Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Mon, 3 Jun 2019 17:21:46 +0800 Subject: [PATCH 01/11] wip --- Tasks/AzureIoTEdgeV2/buildimage.ts | 4 ++-- Tasks/AzureIoTEdgeV2/constant.ts | 3 ++- Tasks/AzureIoTEdgeV2/deployimage.ts | 4 ++++ Tasks/AzureIoTEdgeV2/genconfig.ts | 34 ++++++++++++++++++++++------- Tasks/AzureIoTEdgeV2/task.json | 14 ++++++++++-- Tasks/AzureIoTEdgeV2/util.ts | 5 ++++- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/buildimage.ts b/Tasks/AzureIoTEdgeV2/buildimage.ts index 784c57febab8..abf0f1c4f36b 100644 --- a/Tasks/AzureIoTEdgeV2/buildimage.ts +++ b/Tasks/AzureIoTEdgeV2/buildimage.ts @@ -30,8 +30,8 @@ export async function run() { envList[name] = v.value; } } - - tl.debug(`Following variables will be passed to the iotedgedev command: ${JSON.stringify(envList)}`); + + tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); let outputStream: EchoStream = new EchoStream(); diff --git a/Tasks/AzureIoTEdgeV2/constant.ts b/Tasks/AzureIoTEdgeV2/constant.ts index 75f838f62e78..2cc48772788d 100644 --- a/Tasks/AzureIoTEdgeV2/constant.ts +++ b/Tasks/AzureIoTEdgeV2/constant.ts @@ -15,7 +15,7 @@ export default class Constants { registryUsername: "CONTAINER_REGISTRY_USERNAME", registryPassword: "CONTAINER_REGISTRY_PASSWORD", bypassModules: "BYPASS_MODULES", - deploymentFileOutputPath: "DEPLOYMENT_CONFIG_FILE", + deploymentFileOutputName: "DEPLOYMENT_CONFIG_FILE", deploymentFileOutputFolder: "CONFIG_OUTPUT_DIR", }; public static outputFileFolder = "Build.ArtifactStagingDirectory"; @@ -25,6 +25,7 @@ export default class Constants { public static defaultDockerHubHostname = "docker.io"; public static variableKeyDisableTelemetry = "DISABLE_TELEMETRY"; public static execSyncSilentOption = { silent: true } as IExecSyncOptions; + public static defaultExecOption = {} as IExecSyncOptions; public static UTF8 = "utf8"; public static outputVariableDeploymentPathKey = "DEPLOYMENT_FILE_PATH"; } \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/deployimage.ts b/Tasks/AzureIoTEdgeV2/deployimage.ts index 876c44454a47..e41e16e5c3b5 100644 --- a/Tasks/AzureIoTEdgeV2/deployimage.ts +++ b/Tasks/AzureIoTEdgeV2/deployimage.ts @@ -222,8 +222,12 @@ class imagevalidationtask { tl.debug(JSON.stringify(loginResult)); if (loginResult.code != 0) { tl.warning(tl.loc("InvalidRegistryCredentialWarning", credential.address, loginResult.stderr)); + } else { + tl.loc("LoginRegistrySucess", credential.address); } }); + } else { + tl.debug("No registry credentials found in deployment manifest.") } tl.setVariable("DOCKER_CLI_EXPERIMENTAL", "enabled"); diff --git a/Tasks/AzureIoTEdgeV2/genconfig.ts b/Tasks/AzureIoTEdgeV2/genconfig.ts index c9e8dab28afa..a1f9aea22f71 100644 --- a/Tasks/AzureIoTEdgeV2/genconfig.ts +++ b/Tasks/AzureIoTEdgeV2/genconfig.ts @@ -14,18 +14,33 @@ export async function run() { util.setTaskRootPath(path.dirname(templateFilePath)); util.setupIotedgedev(); - - let envList = { - [Constants.iotedgedevEnv.deploymentFileOutputFolder]: tl.getVariable(Constants.outputFileFolder), - }; - + + let outputPath = tl.getInput('deploymentManifestOutputPath', true); + let outputFileFolder = path.dirname(outputPath); + let outputFileName = path.basename(outputPath); + + let envList = process.env; + if (!envList[Constants.iotedgedevEnv.deploymentFileOutputFolder]) { + envList[Constants.iotedgedevEnv.deploymentFileOutputFolder] = outputFileFolder; + tl.debug(`Setting deployment manifest output folder to ${outputFileFolder}`); + } + if (!envList[Constants.iotedgedevEnv.deploymentFileOutputName]) { + envList[Constants.iotedgedevEnv.deploymentFileOutputName] = outputFileName; + tl.debug(`Setting deployment manifest output file name to ${outputFileName}`) + } + // Pass task variable to sub process let tlVariables = tl.getVariables(); for (let v of tlVariables) { // The variables in VSTS build contains dot, need to convert to underscore. - let name = v.name.replace('.', '_').toUpperCase(); - if (!envList[name]) { - envList[name] = v.value; + if (v.secret){ + let envName = v.name.replace('.', '_').toUpperCase(); + tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); + if (!envList[envName]) { + envList[envName] = v.value; + } else { + tl.warning(`Environment variable ${envName} already exist. Skip setting environment varialbe for secret: ${v.name}.`); + } } } @@ -38,4 +53,7 @@ export async function run() { command += ` --file "${templateFilePath}"`; command += ` --platform "${defaultPlatform}"`; await tl.exec(`${Constants.iotedgedev}`, command, execOptions); + + tl.setVariable(Constants.outputVariableDeploymentPathKey, outputPath); + tl.debug(`Set ${Constants.outputVariableDeploymentPathKey} to ${outputPath}`); } \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index b2425e1a3b62..7d0143ea1cd5 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -51,7 +51,7 @@ "name": "deploymentFilePath", "type": "filePath", "label": "Deployment file", - "defaultValue": "$(System.DefaultWorkingDirectory)/**/*.json", + "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", "required": true, "visibleRule": "action == Deploy to IoT Edge devices", "helpMarkDown": "Select the deployment json file.\n If this task is in **release pipeline**, you need to set the location of deployment file in artifact.(The default value works for most conditions).\n If this task is in **build pipeline**, you need to set it to the path of **Path of output deployment file**." @@ -200,6 +200,15 @@ }, "helpMarkDown": "Add registry credential for pushing docker images to deployment manifest" }, + { + "name": "deploymentManifestOutputPath", + "type": "filePath", + "label": "Output path", + "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", + "visibleRule": "action == Generate deployment manifest", + "required": true, + "helpMarkDown": "The output path of generated deployment manifest" + }, { "name": "bypassModules", "type": "string", @@ -256,7 +265,8 @@ "InvalidRegistryCredentialWarning": "Failed to login %s with given credential. %s", "CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", "StartGenerateDeploymentManifest": "Start generating deployment manifest...", - "FinishGenerateDeploymentManifest": "Finished generating deployment manifest." + "FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", + "LoginRegistrySucess": "Successfully logged in to registry $s" }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/util.ts b/Tasks/AzureIoTEdgeV2/util.ts index a20c3be8a37d..71e83dece317 100644 --- a/Tasks/AzureIoTEdgeV2/util.ts +++ b/Tasks/AzureIoTEdgeV2/util.ts @@ -89,7 +89,7 @@ export default class Util { cmds = [ { path: `sudo`, arg: `apt-get update`, execOption: Constants.execSyncSilentOption }, { path: `sudo`, arg: `apt-get install -y python-setuptools`, execOption: Constants.execSyncSilentOption }, - { path: `sudo`, arg: `pip install ${Constants.iotedgedev}==${version}`, execOption: Constants.execSyncSilentOption }, + { path: `pip`, arg: `install ${Constants.iotedgedev}~=${version}`, execOption: Constants.execSyncSilentOption }, ] } else if (tl.osType() === Constants.osTypeWindows) { cmds = [ @@ -100,6 +100,7 @@ export default class Util { try { for (let cmd of cmds) { let result = tl.execSync(cmd.path, cmd.arg, cmd.execOption); + tl.debug(result.stdout); if (result.code !== 0) { tl.debug(result.stderr); } @@ -110,9 +111,11 @@ export default class Util { } let result = tl.execSync(`${Constants.iotedgedev}`, `--version`, Constants.execSyncSilentOption); + tl.debug(result.stdout); if (result.code === 0) { console.log(tl.loc('DependencyInstallSuccess', Constants.iotedgedev, result.stdout.substring(result.stdout.indexOf("version")))); } else { + tl.error(result.stderr); throw Error(tl.loc('DependencyInstallFail', Constants.iotedgedev)); } } From ecc5b4cf90351ea94da32137c874b7e89fcecb62 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Sun, 9 Jun 2019 19:17:37 +0800 Subject: [PATCH 02/11] improve logging --- .../resources.resjson/en-US/resources.resjson | 9 ++++--- Tasks/AzureIoTEdgeV2/buildimage.ts | 16 ++++++------ Tasks/AzureIoTEdgeV2/deployimage.ts | 12 +++++++-- Tasks/AzureIoTEdgeV2/genconfig.ts | 12 +++------ Tasks/AzureIoTEdgeV2/pushimage.ts | 26 +++++++++++-------- Tasks/AzureIoTEdgeV2/task.json | 10 +++---- Tasks/AzureIoTEdgeV2/task.loc.json | 20 ++++++++++---- Tasks/AzureIoTEdgeV2/util.ts | 20 ++++++++++++-- 8 files changed, 81 insertions(+), 44 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson index 08bdb05afb45..2160ec6ae168 100644 --- a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson @@ -1,7 +1,7 @@ { "loc.friendlyName": "Azure IoT Edge", "loc.helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", - "loc.description": "Build and deploy an Azure IoT Edge image", + "loc.description": "[Internal Test] Build and deploy an Azure IoT Edge image", "loc.instanceNameFormat": "Azure IoT Edge - $(action)", "loc.group.displayName.advanced_push": "Advanced", "loc.group.displayName.advanced_deploy": "Advanced", @@ -37,6 +37,8 @@ "loc.input.help.defaultPlatform": "In your **.template.json**, you can leave the modules platform unspecified. For these modules, the **default platform** will be used.", "loc.input.label.fillRegistryCredential": "Add registry credential to deployment manifest", "loc.input.help.fillRegistryCredential": "Add registry credential for pushing docker images to deployment manifest", + "loc.input.label.deploymentManifestOutputPath": "Output path", + "loc.input.help.deploymentManifestOutputPath": "The output path of generated deployment manifest", "loc.input.label.bypassModules": "Bypass module(s)", "loc.input.help.bypassModules": "Select the module(s) that you **DO NOT** need to build(or push) in the .template.json, specify module names and separate with comma.\n Example: if you have 2 modules **SampleModule1,SampleModule2** in your .template.json, you want to just build or push **SampleModule1**, then you set the bypass modules as **SampleModule2**. Leave empty if you would like to build all the modules in .template.json.", "loc.messages.BuildingModules": "Building module images...", @@ -57,7 +59,7 @@ "loc.messages.DependencyInstallSuccess": "%s installed with version: %s", "loc.messages.DependencyInstallFail": "%s installation failed, see detailed error in debug mode", "loc.messages.TemplateFileInvalid": "The path of template file is not valid: %s", - "loc.messages.ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The token is %s", + "loc.messages.ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", "loc.messages.DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", "loc.messages.ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", "loc.messages.AzureSdkNotFound": "Azure SDK not found", @@ -66,5 +68,6 @@ "loc.messages.InvalidRegistryCredentialWarning": "Failed to login %s with given credential. %s", "loc.messages.CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", "loc.messages.StartGenerateDeploymentManifest": "Start generating deployment manifest...", - "loc.messages.FinishGenerateDeploymentManifest": "Finished generating deployment manifest." + "loc.messages.FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", + "loc.messages.LoginRegistrySucess": "Successfully logged in to registry $s" } \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/buildimage.ts b/Tasks/AzureIoTEdgeV2/buildimage.ts index abf0f1c4f36b..0336e322a81c 100644 --- a/Tasks/AzureIoTEdgeV2/buildimage.ts +++ b/Tasks/AzureIoTEdgeV2/buildimage.ts @@ -17,20 +17,20 @@ export async function run() { util.setupIotedgedev(); - let envList = { - [Constants.iotedgedevEnv.deploymentFileOutputFolder]: tl.getVariable(Constants.outputFileFolder), - }; + let envList = process.env; + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, tl.getVariable(Constants.outputFileFolder)); // Pass task variable to sub process let tlVariables = tl.getVariables(); for (let v of tlVariables) { // The variables in VSTS build contains dot, need to convert to underscore. - let name = v.name.replace('.', '_').toUpperCase(); - if (!envList[name]) { - envList[name] = v.value; + if (v.secret) { + let envName = v.name.replace('.', '_').toUpperCase(); + tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); + util.setEnvrionmentVarialbe(envList, envName, v.value); } } - + tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); let outputStream: EchoStream = new EchoStream(); @@ -49,7 +49,7 @@ export async function run() { let outLog: string = outputStream.content; let filterReg: RegExp = /Expanding '[^']*' to '([^']*)'/g; let matches: RegExpMatchArray = filterReg.exec(outLog); - if(matches && matches[1]) { + if (matches && matches[1]) { tl.setVariable(Constants.outputVariableDeploymentPathKey, matches[1]); tl.setVariable('_' + Constants.outputVariableDeploymentPathKey, matches[1]); tl.debug(`Set ${Constants.outputVariableDeploymentPathKey} to ${matches[1]}`); diff --git a/Tasks/AzureIoTEdgeV2/deployimage.ts b/Tasks/AzureIoTEdgeV2/deployimage.ts index e41e16e5c3b5..3142f69224f6 100644 --- a/Tasks/AzureIoTEdgeV2/deployimage.ts +++ b/Tasks/AzureIoTEdgeV2/deployimage.ts @@ -6,6 +6,9 @@ import util from "./util"; import Constants from "./constant"; import { IExecSyncOptions } from 'azure-pipelines-task-lib/toolrunner'; import { TelemetryEvent } from './telemetry'; +import * as stream from "stream"; +import EchoStream from './echostream'; +import { IExecOptions } from 'azure-pipelines-task-lib/toolrunner'; class azureclitask { private static isLoggedIn = false; @@ -87,10 +90,15 @@ class azureclitask { // If error when get iot hub information, ignore. } + let outputStream: EchoStream = new EchoStream(); + let execOptions: IExecOptions = { + errStream: outputStream as stream.Writable + } as IExecOptions; + let result1 = tl.execSync('az', script1, Constants.execSyncSilentOption); - let result2 = await tl.exec('az', script2); + let result2 = await tl.exec('az', script2, execOptions); if (result2 !== 0) { - throw new Error(`Error for deployment`); + throw new Error(`Failed to create deployment. Error: ${outputStream.content}`); } } catch (err) { diff --git a/Tasks/AzureIoTEdgeV2/genconfig.ts b/Tasks/AzureIoTEdgeV2/genconfig.ts index a1f9aea22f71..e5bf4861a928 100644 --- a/Tasks/AzureIoTEdgeV2/genconfig.ts +++ b/Tasks/AzureIoTEdgeV2/genconfig.ts @@ -20,14 +20,10 @@ export async function run() { let outputFileName = path.basename(outputPath); let envList = process.env; - if (!envList[Constants.iotedgedevEnv.deploymentFileOutputFolder]) { - envList[Constants.iotedgedevEnv.deploymentFileOutputFolder] = outputFileFolder; - tl.debug(`Setting deployment manifest output folder to ${outputFileFolder}`); - } - if (!envList[Constants.iotedgedevEnv.deploymentFileOutputName]) { - envList[Constants.iotedgedevEnv.deploymentFileOutputName] = outputFileName; - tl.debug(`Setting deployment manifest output file name to ${outputFileName}`) - } + tl.debug(`Setting deployment manifest output folder to ${outputFileFolder}`); + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, outputFileFolder); + tl.debug(`Setting deployment manifest output file name to ${outputFileName}`) + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputName, outputFileName) // Pass task variable to sub process let tlVariables = tl.getVariables(); diff --git a/Tasks/AzureIoTEdgeV2/pushimage.ts b/Tasks/AzureIoTEdgeV2/pushimage.ts index 10584c47b653..60c399a7bc3e 100644 --- a/Tasks/AzureIoTEdgeV2/pushimage.ts +++ b/Tasks/AzureIoTEdgeV2/pushimage.ts @@ -20,7 +20,11 @@ function getRegistryAuthenticationToken(): RegistryCredential { } if (token == null || token.username == null || token.password == null || token.serverUrl == null) { - throw Error(tl.loc('ContainerRegistryInvalid', JSON.stringify(token))); + let username = ""; + if (token != null && token.username != null) { + username = token.username; + } + throw Error(tl.loc('ContainerRegistryInvalid', username)); } return token; } @@ -52,24 +56,24 @@ export async function run() { */ tl.execSync(`docker`, `login -u "${registryAuthenticationToken.username}" -p "${registryAuthenticationToken.password}" ${registryAuthenticationToken.serverUrl}`, Constants.execSyncSilentOption) - let envList = { - [Constants.iotedgedevEnv.bypassModules]: bypassModules, - [Constants.iotedgedevEnv.registryServer]: registryAuthenticationToken.serverUrl, - [Constants.iotedgedevEnv.registryUsername]: registryAuthenticationToken.username, - [Constants.iotedgedevEnv.registryPassword]: registryAuthenticationToken.password, - }; + let envList = process.env; + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.bypassModules, bypassModules); + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryServer, registryAuthenticationToken.serverUrl); + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryUsername, registryAuthenticationToken.username); + util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryPassword, registryAuthenticationToken.password); // Pass task variable to sub process let tlVariables = tl.getVariables(); for (let v of tlVariables) { // The variables in VSTS build contains dot, need to convert to underscore. - let name = v.name.replace('.', '_').toUpperCase(); - if (!envList[name]) { - envList[name] = v.value; + if (v.secret) { + let envName = v.name.replace('.', '_').toUpperCase(); + tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); + util.setEnvrionmentVarialbe(envList, envName, v.value); } } - tl.debug(`Following variables will be passed to the iotedgedev command: ${JSON.stringify(envList)}`); + tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); try { let execOptions: IExecOptions = { diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index 7d0143ea1cd5..d00d3498e8e2 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -1,8 +1,8 @@ { - "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", + "id": "e4c41a58-1cf2-44af-832a-7dc05c8d1394", "name": "AzureIoTEdge", "friendlyName": "Azure IoT Edge", - "description": "Build and deploy an Azure IoT Edge image", + "description": "[Internal Test] Build and deploy an Azure IoT Edge image", "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/build/azure-iot-edge", "helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", "category": "Build", @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 1, - "Patch": 4 + "Minor": 2, + "Patch": 0 }, "preview": true, "instanceNameFormat": "Azure IoT Edge - $(action)", @@ -256,7 +256,7 @@ "DependencyInstallSuccess": "%s installed with version: %s", "DependencyInstallFail": "%s installation failed, see detailed error in debug mode", "TemplateFileInvalid": "The path of template file is not valid: %s", - "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The token is %s", + "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", "DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", "ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", "AzureSdkNotFound": "Azure SDK not found", diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index d3efc6c7b568..db4603187df3 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -1,5 +1,5 @@ { - "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", + "id": "e4c41a58-1cf2-44af-832a-7dc05c8d1394", "name": "AzureIoTEdge", "friendlyName": "ms-resource:loc.friendlyName", "description": "ms-resource:loc.description", @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 1, - "Patch": 4 + "Minor": 2, + "Patch": 0 }, "preview": true, "instanceNameFormat": "ms-resource:loc.instanceNameFormat", @@ -51,7 +51,7 @@ "name": "deploymentFilePath", "type": "filePath", "label": "ms-resource:loc.input.label.deploymentFilePath", - "defaultValue": "$(System.DefaultWorkingDirectory)/**/*.json", + "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", "required": true, "visibleRule": "action == Deploy to IoT Edge devices", "helpMarkDown": "ms-resource:loc.input.help.deploymentFilePath" @@ -200,6 +200,15 @@ }, "helpMarkDown": "ms-resource:loc.input.help.fillRegistryCredential" }, + { + "name": "deploymentManifestOutputPath", + "type": "filePath", + "label": "ms-resource:loc.input.label.deploymentManifestOutputPath", + "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", + "visibleRule": "action == Generate deployment manifest", + "required": true, + "helpMarkDown": "ms-resource:loc.input.help.deploymentManifestOutputPath" + }, { "name": "bypassModules", "type": "string", @@ -256,7 +265,8 @@ "InvalidRegistryCredentialWarning": "ms-resource:loc.messages.InvalidRegistryCredentialWarning", "CheckModuleImageExistenceError": "ms-resource:loc.messages.CheckModuleImageExistenceError", "StartGenerateDeploymentManifest": "ms-resource:loc.messages.StartGenerateDeploymentManifest", - "FinishGenerateDeploymentManifest": "ms-resource:loc.messages.FinishGenerateDeploymentManifest" + "FinishGenerateDeploymentManifest": "ms-resource:loc.messages.FinishGenerateDeploymentManifest", + "LoginRegistrySucess": "ms-resource:loc.messages.LoginRegistrySucess" }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/util.ts b/Tasks/AzureIoTEdgeV2/util.ts index 71e83dece317..accf8d3c4418 100644 --- a/Tasks/AzureIoTEdgeV2/util.ts +++ b/Tasks/AzureIoTEdgeV2/util.ts @@ -89,7 +89,8 @@ export default class Util { cmds = [ { path: `sudo`, arg: `apt-get update`, execOption: Constants.execSyncSilentOption }, { path: `sudo`, arg: `apt-get install -y python-setuptools`, execOption: Constants.execSyncSilentOption }, - { path: `pip`, arg: `install ${Constants.iotedgedev}~=${version}`, execOption: Constants.execSyncSilentOption }, + { path: `sudo`, arg: `pip install --upgrade cryptography`, execOption: Constants.execSyncSilentOption}, + { path: `sudo`, arg: `pip install ${Constants.iotedgedev}~=${version}`, execOption: Constants.execSyncSilentOption }, ] } else if (tl.osType() === Constants.osTypeWindows) { cmds = [ @@ -207,7 +208,7 @@ export default class Util { } public static normalizeDeploymentId(id: string): string { - if(id.length > 128) { + if (id.length > 128) { id = id.substring(0, 128); } id = id.toLowerCase(); @@ -224,4 +225,19 @@ export default class Util { } return true; } + + public static setEnvrionmentVarialbe(envList: NodeJS.ProcessEnv, envName: string, envValue: string, overrideExisting: boolean = false): void { + if (envList[envName]) { + if (overrideExisting) { + tl.warning(`The environment variable ${envName} already exists and will be overrided with the new value.`); + envList[envName] = envValue; + return; + } else { + tl.warning(`The environment variable ${envName} already exists so will no been overrided.`) + return; + } + } + tl.debug(`Setting the valud of environment variable ${envName}`); + envList[envName] = envValue; + } } \ No newline at end of file From 7dc650968c1fe98dcf05529597e3473c213d5648 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Sun, 9 Jun 2019 19:21:24 +0800 Subject: [PATCH 03/11] revert test resources --- .../Strings/resources.resjson/en-US/resources.resjson | 2 +- Tasks/AzureIoTEdgeV2/task.json | 4 ++-- Tasks/AzureIoTEdgeV2/task.loc.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson index 2160ec6ae168..c05315df4222 100644 --- a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson @@ -1,7 +1,7 @@ { "loc.friendlyName": "Azure IoT Edge", "loc.helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", - "loc.description": "[Internal Test] Build and deploy an Azure IoT Edge image", + "loc.description": "Build and deploy an Azure IoT Edge image", "loc.instanceNameFormat": "Azure IoT Edge - $(action)", "loc.group.displayName.advanced_push": "Advanced", "loc.group.displayName.advanced_deploy": "Advanced", diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index d00d3498e8e2..be63a466891f 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -1,8 +1,8 @@ { - "id": "e4c41a58-1cf2-44af-832a-7dc05c8d1394", + "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", "name": "AzureIoTEdge", "friendlyName": "Azure IoT Edge", - "description": "[Internal Test] Build and deploy an Azure IoT Edge image", + "description": "Build and deploy an Azure IoT Edge image", "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/build/azure-iot-edge", "helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", "category": "Build", diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index db4603187df3..8adbbc07c51a 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -1,5 +1,5 @@ { - "id": "e4c41a58-1cf2-44af-832a-7dc05c8d1394", + "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", "name": "AzureIoTEdge", "friendlyName": "ms-resource:loc.friendlyName", "description": "ms-resource:loc.description", From f5c3dde9eb1741b4372c3a894b114bdab7036697 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Sun, 9 Jun 2019 20:25:39 +0800 Subject: [PATCH 04/11] show environment variable setting --- Tasks/AzureIoTEdgeV2/task.json | 3 ++- Tasks/AzureIoTEdgeV2/task.loc.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index be63a466891f..373ca2c6c440 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -16,7 +16,8 @@ "Minor": 2, "Patch": 0 }, - "preview": true, + "preview": false, + "showEnvironmentVariables": true, "instanceNameFormat": "Azure IoT Edge - $(action)", "groups": [ { diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index 8adbbc07c51a..4a015ab68cf0 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -16,7 +16,8 @@ "Minor": 2, "Patch": 0 }, - "preview": true, + "preview": false, + "showEnvironmentVariables": true, "instanceNameFormat": "ms-resource:loc.instanceNameFormat", "groups": [ { From ed1425474e4a5bcbda398b3dd6367b15084838d1 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Sun, 9 Jun 2019 20:51:30 +0800 Subject: [PATCH 05/11] remove temp files --- Tasks/AzureIoTEdgeV2/task_BACKUP_14864.json | 284 -------------------- Tasks/AzureIoTEdgeV2/task_BASE_14864.json | 268 ------------------ Tasks/AzureIoTEdgeV2/task_LOCAL_14864.json | 279 ------------------- Tasks/AzureIoTEdgeV2/task_REMOTE_14864.json | 268 ------------------ 4 files changed, 1099 deletions(-) delete mode 100644 Tasks/AzureIoTEdgeV2/task_BACKUP_14864.json delete mode 100644 Tasks/AzureIoTEdgeV2/task_BASE_14864.json delete mode 100644 Tasks/AzureIoTEdgeV2/task_LOCAL_14864.json delete mode 100644 Tasks/AzureIoTEdgeV2/task_REMOTE_14864.json diff --git a/Tasks/AzureIoTEdgeV2/task_BACKUP_14864.json b/Tasks/AzureIoTEdgeV2/task_BACKUP_14864.json deleted file mode 100644 index 8984c5ee0397..000000000000 --- a/Tasks/AzureIoTEdgeV2/task_BACKUP_14864.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", - "name": "AzureIoTEdge", - "friendlyName": "Azure IoT Edge", - "description": "Build and deploy an Azure IoT Edge image", - "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/build/azure-iot-edge", - "helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", - "category": "Build", - "visibility": [ - "Build", - "Release" - ], - "author": "Microsoft Corporation", - "version": { - "Major": 2, -<<<<<<< HEAD - "Minor": 2, - "Patch": 0 -======= - "Minor": 1, - "Patch": 5 ->>>>>>> master - }, - "preview": false, - "showEnvironmentVariables": true, - "instanceNameFormat": "Azure IoT Edge - $(action)", - "groups": [ - { - "name": "advanced_push", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Push module images" - }, - { - "name": "advanced_deploy", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Deploy to IoT Edge devices" - } - ], - "inputs": [ - { - "name": "action", - "type": "pickList", - "label": "Action", - "defaultValue": "Build module images", - "required": true, - "options": { - "Build module images": "Build module images", - "Push module images": "Push module images", - "Generate deployment manifest": "Generate deployment manifest", - "Deploy to IoT Edge devices": "Deploy to IoT Edge devices" - }, - "helpMarkDown": "Select an Azure IoT Edge action.\n **Build module images** will only build modules (You can use it to check compilation error).\n **Push module images** will push modules to container registry.\n **Deploy to IoT Edge devices** will deploy the generated deployment file to IoT Hub. (We recommend to put **Deploy** task in release pipeline)." - }, - { - "name": "deploymentFilePath", - "type": "filePath", - "label": "Deployment file", - "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the deployment json file.\n If this task is in **release pipeline**, you need to set the location of deployment file in artifact.(The default value works for most conditions).\n If this task is in **build pipeline**, you need to set it to the path of **Path of output deployment file**." - }, - { - "name": "connectedServiceNameARM", - "aliases": [ - "azureSubscription" - ], - "type": "connectedService:AzureRM", - "label": "Azure subscription contains IoT Hub", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select an **Azure subscription** that contains IoT Hub" - }, - { - "name": "iothubname", - "type": "pickList", - "label": "IoT Hub name", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the **IoT Hub**" - }, - { - "name": "deploymentid", - "type": "string", - "label": "IoT Edge deployment ID", - "required": true, - "defaultValue": "$(System.TeamProject)-devops-deployment", - "helpMarkDown": "Input the **IoT Edge Deployment ID**, if ID exists, it will be overridden.\n Up to 128 lowercase letters, numbers and the following characters are allowed [ -:+%_#*?!(),=@;' ].\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "priority", - "type": "string", - "label": "IoT Edge deployment priority", - "required": true, - "defaultValue": "0", - "helpMarkDown": "Set the **priority** to a positive integer to resolve deployment conflicts: when targeted by multiple deployments a device will use the one with highest priority or (in case of two deployments with the same priority) latest creation time.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "deviceOption", - "type": "pickList", - "label": "Choose single/multiple device", - "required": true, - "options": { - "Single Device": "Single Device", - "Multiple Devices": "Multiple Devices" - }, - "helpMarkDown": "Choose to deploy to single or multiple(by tags) devices", - "visibleRule": "action == Deploy to IoT Edge devices" - }, - { - "name": "deviceId", - "type": "string", - "label": "IoT Edge device ID", - "required": true, - "visibleRule": "deviceOption == Single Device", - "helpMarkDown": "Input the IoT Edge **device ID**" - }, - { - "name": "targetcondition", - "type": "string", - "label": "IoT Edge device target condition", - "required": true, - "visibleRule": "deviceOption == Multiple Devices", - "helpMarkDown": "Input the **target condition** of devices you would like to deploy. Do not use double quote. Example: **tags.building=9 and tags.environment='test'**.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)" - }, - { - "name": "containerregistrytype", - "type": "pickList", - "label": "Container registry type", - "defaultValue": "Azure Container Registry", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "Azure Container Registry": "Azure Container Registry", - "Generic Container Registry": "Generic Container Registry" - }, - "helpMarkDown": "Select a **Container Registry Type**.\n **Azure Container Registry** for ACR and **Generic Container Registry** for generic registries including docker hub." - }, - { - "name": "dockerRegistryEndpoint", - "aliases": [ - "dockerRegistryConnection" - ], - "type": "connectedService:dockerregistry", - "required": true, - "label": "Docker Registry Connection", - "helpMarkDown": "Select a generic **Docker registry connection**. Required for **Build and Push**.", - "visibleRule": "containerregistrytype = Generic Container Registry" - }, - { - "name": "azureSubscriptionEndpoint", - "type": "connectedService:AzureRM", - "label": "Azure subscription", - "helpMarkDown": "Select an Azure subscription", - "visibleRule": "containerregistrytype = Azure Container Registry" - }, - { - "name": "azureContainerRegistry", - "label": "Azure Container Registry", - "type": "pickList", - "required": true, - "helpMarkDown": "Select an **Azure Container Registry**", - "visibleRule": "containerregistrytype = Azure Container Registry", - "defaultValue": "" - }, - { - "name": "templateFilePath", - "type": "filePath", - "label": ".template.json file", - "defaultValue": "deployment.template.json", - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "required": true, - "helpMarkDown": "The path of Azure IoT Edge solution **.template.json**. This file defines the modules and routes in Azure IoT Edge solution, file name must end with **.template.json**" - }, - { - "name": "defaultPlatform", - "type": "pickList", - "label": "Default platform", - "defaultValue": "amd64", - "required": true, - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "options": { - "amd64": "amd64", - "windows-amd64": "windows-amd64", - "arm32v7": "arm32v7" - }, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "In your **.template.json**, you can leave the modules platform unspecified. For these modules, the **default platform** will be used." - }, - { - "name": "fillRegistryCredential", - "type": "pickList", - "label": "Add registry credential to deployment manifest", - "defaultValue": "true", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "true": "true", - "false": "false" - }, - "helpMarkDown": "Add registry credential for pushing docker images to deployment manifest" - }, - { - "name": "deploymentManifestOutputPath", - "type": "filePath", - "label": "Output path", - "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", - "visibleRule": "action == Generate deployment manifest", - "required": true, - "helpMarkDown": "The output path of generated deployment manifest" - }, - { - "name": "bypassModules", - "type": "string", - "label": "Bypass module(s)", - "defaultValue": "", - "helpMarkDown": "Select the module(s) that you **DO NOT** need to build(or push) in the .template.json, specify module names and separate with comma.\n Example: if you have 2 modules **SampleModule1,SampleModule2** in your .template.json, you want to just build or push **SampleModule1**, then you set the bypass modules as **SampleModule2**. Leave empty if you would like to build all the modules in .template.json.", - "groupName": "advanced_push" - } - ], - "dataSourceBindings": [ - { - "target": "azureContainerRegistry", - "endpointId": "$(azureSubscriptionEndpoint)", - "dataSourceName": "AzureRMContainerRegistries", - "resultTemplate": "{\"Value\":\"{\\\"loginServer\\\":\\\"{{{properties.loginServer}}}\\\", \\\"id\\\" : \\\"{{{id}}}\\\"}\",\"DisplayValue\":\"{{{name}}}\"}" - }, - { - "target": "iothubname", - "endpointId": "$(connectedServiceNameARM)", - "endpointUrl": "{{{endpoint.url}}}/subscriptions/{{{endpoint.subscriptionId}}}/providers/Microsoft.Devices/IotHubs?api-version=2018-04-01", - "resultSelector": "jsonpath:$.value[*].name" - } - ], - "execution": { - "Node": { - "target": "index.js" - } - }, - "messages": { - "BuildingModules": "Building module images...", - "BuildingModulesFinished": "Finished building module images", - "PushingModules": "Pushing module images...", - "PushingModulesFinished": "Finished pushing module images", - "StartDeploy": "Start deploying...", - "FinishDeploy": "Finished Deploying", - "DeploymentFilePath": "The generated deployment file located in the path: %s", - "ExpandingRegistryCredentials": "Expanding registry credentials in deployment file...", - "ReplaceCredential": "Replace credential: %s", - "DeployTaskRunningInBuild": "Deployment task is running in build pipeline? %s", - "CheckValidJson": "Checking if the following file is a valid json: %s", - "Invalid": "Invalid", - "Valid": "Valid", - "NomralizedDeployementId": "Normalized deployment id is: %s", - "DependencyAlreadyInstalled": "%s already installed with version: %s", - "DependencyInstallSuccess": "%s installed with version: %s", - "DependencyInstallFail": "%s installation failed, see detailed error in debug mode", - "TemplateFileInvalid": "The path of template file is not valid: %s", - "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", - "DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", - "ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", - "AzureSdkNotFound": "Azure SDK not found", - "RootPathNotExist": "The Root path %s does not exist", - "SkipModuleImageValidation": "SKIP_MODULE_IMAGE_VALIDATION set to true, skipping module image validation.", - "InvalidRegistryCredentialWarning": "Failed to login %s with given credential. %s", - "CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", - "StartGenerateDeploymentManifest": "Start generating deployment manifest...", - "FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", - "LoginRegistrySucess": "Successfully logged in to registry $s" - }, - "OutputVariables": [ - { - "name": "DEPLOYMENT_FILE_PATH", - "description": "This is the path of generated deployment file.", - "visibleRule": "action = Build module images" - } - ] -} \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/task_BASE_14864.json b/Tasks/AzureIoTEdgeV2/task_BASE_14864.json deleted file mode 100644 index b2425e1a3b62..000000000000 --- a/Tasks/AzureIoTEdgeV2/task_BASE_14864.json +++ /dev/null @@ -1,268 +0,0 @@ -{ - "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", - "name": "AzureIoTEdge", - "friendlyName": "Azure IoT Edge", - "description": "Build and deploy an Azure IoT Edge image", - "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/build/azure-iot-edge", - "helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", - "category": "Build", - "visibility": [ - "Build", - "Release" - ], - "author": "Microsoft Corporation", - "version": { - "Major": 2, - "Minor": 1, - "Patch": 4 - }, - "preview": true, - "instanceNameFormat": "Azure IoT Edge - $(action)", - "groups": [ - { - "name": "advanced_push", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Push module images" - }, - { - "name": "advanced_deploy", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Deploy to IoT Edge devices" - } - ], - "inputs": [ - { - "name": "action", - "type": "pickList", - "label": "Action", - "defaultValue": "Build module images", - "required": true, - "options": { - "Build module images": "Build module images", - "Push module images": "Push module images", - "Generate deployment manifest": "Generate deployment manifest", - "Deploy to IoT Edge devices": "Deploy to IoT Edge devices" - }, - "helpMarkDown": "Select an Azure IoT Edge action.\n **Build module images** will only build modules (You can use it to check compilation error).\n **Push module images** will push modules to container registry.\n **Deploy to IoT Edge devices** will deploy the generated deployment file to IoT Hub. (We recommend to put **Deploy** task in release pipeline)." - }, - { - "name": "deploymentFilePath", - "type": "filePath", - "label": "Deployment file", - "defaultValue": "$(System.DefaultWorkingDirectory)/**/*.json", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the deployment json file.\n If this task is in **release pipeline**, you need to set the location of deployment file in artifact.(The default value works for most conditions).\n If this task is in **build pipeline**, you need to set it to the path of **Path of output deployment file**." - }, - { - "name": "connectedServiceNameARM", - "aliases": [ - "azureSubscription" - ], - "type": "connectedService:AzureRM", - "label": "Azure subscription contains IoT Hub", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select an **Azure subscription** that contains IoT Hub" - }, - { - "name": "iothubname", - "type": "pickList", - "label": "IoT Hub name", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the **IoT Hub**" - }, - { - "name": "deploymentid", - "type": "string", - "label": "IoT Edge deployment ID", - "required": true, - "defaultValue": "$(System.TeamProject)-devops-deployment", - "helpMarkDown": "Input the **IoT Edge Deployment ID**, if ID exists, it will be overridden.\n Up to 128 lowercase letters, numbers and the following characters are allowed [ -:+%_#*?!(),=@;' ].\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "priority", - "type": "string", - "label": "IoT Edge deployment priority", - "required": true, - "defaultValue": "0", - "helpMarkDown": "Set the **priority** to a positive integer to resolve deployment conflicts: when targeted by multiple deployments a device will use the one with highest priority or (in case of two deployments with the same priority) latest creation time.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "deviceOption", - "type": "pickList", - "label": "Choose single/multiple device", - "required": true, - "options": { - "Single Device": "Single Device", - "Multiple Devices": "Multiple Devices" - }, - "helpMarkDown": "Choose to deploy to single or multiple(by tags) devices", - "visibleRule": "action == Deploy to IoT Edge devices" - }, - { - "name": "deviceId", - "type": "string", - "label": "IoT Edge device ID", - "required": true, - "visibleRule": "deviceOption == Single Device", - "helpMarkDown": "Input the IoT Edge **device ID**" - }, - { - "name": "targetcondition", - "type": "string", - "label": "IoT Edge device target condition", - "required": true, - "visibleRule": "deviceOption == Multiple Devices", - "helpMarkDown": "Input the **target condition** of devices you would like to deploy. Do not use double quote. Example: **tags.building=9 and tags.environment='test'**.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)" - }, - { - "name": "containerregistrytype", - "type": "pickList", - "label": "Container registry type", - "defaultValue": "Azure Container Registry", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "Azure Container Registry": "Azure Container Registry", - "Generic Container Registry": "Generic Container Registry" - }, - "helpMarkDown": "Select a **Container Registry Type**.\n **Azure Container Registry** for ACR and **Generic Container Registry** for generic registries including docker hub." - }, - { - "name": "dockerRegistryEndpoint", - "aliases": [ - "dockerRegistryConnection" - ], - "type": "connectedService:dockerregistry", - "required": true, - "label": "Docker Registry Connection", - "helpMarkDown": "Select a generic **Docker registry connection**. Required for **Build and Push**.", - "visibleRule": "containerregistrytype = Generic Container Registry" - }, - { - "name": "azureSubscriptionEndpoint", - "type": "connectedService:AzureRM", - "label": "Azure subscription", - "helpMarkDown": "Select an Azure subscription", - "visibleRule": "containerregistrytype = Azure Container Registry" - }, - { - "name": "azureContainerRegistry", - "label": "Azure Container Registry", - "type": "pickList", - "required": true, - "helpMarkDown": "Select an **Azure Container Registry**", - "visibleRule": "containerregistrytype = Azure Container Registry", - "defaultValue": "" - }, - { - "name": "templateFilePath", - "type": "filePath", - "label": ".template.json file", - "defaultValue": "deployment.template.json", - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "required": true, - "helpMarkDown": "The path of Azure IoT Edge solution **.template.json**. This file defines the modules and routes in Azure IoT Edge solution, file name must end with **.template.json**" - }, - { - "name": "defaultPlatform", - "type": "pickList", - "label": "Default platform", - "defaultValue": "amd64", - "required": true, - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "options": { - "amd64": "amd64", - "windows-amd64": "windows-amd64", - "arm32v7": "arm32v7" - }, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "In your **.template.json**, you can leave the modules platform unspecified. For these modules, the **default platform** will be used." - }, - { - "name": "fillRegistryCredential", - "type": "pickList", - "label": "Add registry credential to deployment manifest", - "defaultValue": "true", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "true": "true", - "false": "false" - }, - "helpMarkDown": "Add registry credential for pushing docker images to deployment manifest" - }, - { - "name": "bypassModules", - "type": "string", - "label": "Bypass module(s)", - "defaultValue": "", - "helpMarkDown": "Select the module(s) that you **DO NOT** need to build(or push) in the .template.json, specify module names and separate with comma.\n Example: if you have 2 modules **SampleModule1,SampleModule2** in your .template.json, you want to just build or push **SampleModule1**, then you set the bypass modules as **SampleModule2**. Leave empty if you would like to build all the modules in .template.json.", - "groupName": "advanced_push" - } - ], - "dataSourceBindings": [ - { - "target": "azureContainerRegistry", - "endpointId": "$(azureSubscriptionEndpoint)", - "dataSourceName": "AzureRMContainerRegistries", - "resultTemplate": "{\"Value\":\"{\\\"loginServer\\\":\\\"{{{properties.loginServer}}}\\\", \\\"id\\\" : \\\"{{{id}}}\\\"}\",\"DisplayValue\":\"{{{name}}}\"}" - }, - { - "target": "iothubname", - "endpointId": "$(connectedServiceNameARM)", - "endpointUrl": "{{{endpoint.url}}}/subscriptions/{{{endpoint.subscriptionId}}}/providers/Microsoft.Devices/IotHubs?api-version=2018-04-01", - "resultSelector": "jsonpath:$.value[*].name" - } - ], - "execution": { - "Node": { - "target": "index.js" - } - }, - "messages": { - "BuildingModules": "Building module images...", - "BuildingModulesFinished": "Finished building module images", - "PushingModules": "Pushing module images...", - "PushingModulesFinished": "Finished pushing module images", - "StartDeploy": "Start deploying...", - "FinishDeploy": "Finished Deploying", - "DeploymentFilePath": "The generated deployment file located in the path: %s", - "ExpandingRegistryCredentials": "Expanding registry credentials in deployment file...", - "ReplaceCredential": "Replace credential: %s", - "DeployTaskRunningInBuild": "Deployment task is running in build pipeline? %s", - "CheckValidJson": "Checking if the following file is a valid json: %s", - "Invalid": "Invalid", - "Valid": "Valid", - "NomralizedDeployementId": "Normalized deployment id is: %s", - "DependencyAlreadyInstalled": "%s already installed with version: %s", - "DependencyInstallSuccess": "%s installed with version: %s", - "DependencyInstallFail": "%s installation failed, see detailed error in debug mode", - "TemplateFileInvalid": "The path of template file is not valid: %s", - "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The token is %s", - "DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", - "ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", - "AzureSdkNotFound": "Azure SDK not found", - "RootPathNotExist": "The Root path %s does not exist", - "SkipModuleImageValidation": "SKIP_MODULE_IMAGE_VALIDATION set to true, skipping module image validation.", - "InvalidRegistryCredentialWarning": "Failed to login %s with given credential. %s", - "CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", - "StartGenerateDeploymentManifest": "Start generating deployment manifest...", - "FinishGenerateDeploymentManifest": "Finished generating deployment manifest." - }, - "OutputVariables": [ - { - "name": "DEPLOYMENT_FILE_PATH", - "description": "This is the path of generated deployment file.", - "visibleRule": "action = Build module images" - } - ] -} \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/task_LOCAL_14864.json b/Tasks/AzureIoTEdgeV2/task_LOCAL_14864.json deleted file mode 100644 index 373ca2c6c440..000000000000 --- a/Tasks/AzureIoTEdgeV2/task_LOCAL_14864.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", - "name": "AzureIoTEdge", - "friendlyName": "Azure IoT Edge", - "description": "Build and deploy an Azure IoT Edge image", - "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/build/azure-iot-edge", - "helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", - "category": "Build", - "visibility": [ - "Build", - "Release" - ], - "author": "Microsoft Corporation", - "version": { - "Major": 2, - "Minor": 2, - "Patch": 0 - }, - "preview": false, - "showEnvironmentVariables": true, - "instanceNameFormat": "Azure IoT Edge - $(action)", - "groups": [ - { - "name": "advanced_push", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Push module images" - }, - { - "name": "advanced_deploy", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Deploy to IoT Edge devices" - } - ], - "inputs": [ - { - "name": "action", - "type": "pickList", - "label": "Action", - "defaultValue": "Build module images", - "required": true, - "options": { - "Build module images": "Build module images", - "Push module images": "Push module images", - "Generate deployment manifest": "Generate deployment manifest", - "Deploy to IoT Edge devices": "Deploy to IoT Edge devices" - }, - "helpMarkDown": "Select an Azure IoT Edge action.\n **Build module images** will only build modules (You can use it to check compilation error).\n **Push module images** will push modules to container registry.\n **Deploy to IoT Edge devices** will deploy the generated deployment file to IoT Hub. (We recommend to put **Deploy** task in release pipeline)." - }, - { - "name": "deploymentFilePath", - "type": "filePath", - "label": "Deployment file", - "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the deployment json file.\n If this task is in **release pipeline**, you need to set the location of deployment file in artifact.(The default value works for most conditions).\n If this task is in **build pipeline**, you need to set it to the path of **Path of output deployment file**." - }, - { - "name": "connectedServiceNameARM", - "aliases": [ - "azureSubscription" - ], - "type": "connectedService:AzureRM", - "label": "Azure subscription contains IoT Hub", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select an **Azure subscription** that contains IoT Hub" - }, - { - "name": "iothubname", - "type": "pickList", - "label": "IoT Hub name", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the **IoT Hub**" - }, - { - "name": "deploymentid", - "type": "string", - "label": "IoT Edge deployment ID", - "required": true, - "defaultValue": "$(System.TeamProject)-devops-deployment", - "helpMarkDown": "Input the **IoT Edge Deployment ID**, if ID exists, it will be overridden.\n Up to 128 lowercase letters, numbers and the following characters are allowed [ -:+%_#*?!(),=@;' ].\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "priority", - "type": "string", - "label": "IoT Edge deployment priority", - "required": true, - "defaultValue": "0", - "helpMarkDown": "Set the **priority** to a positive integer to resolve deployment conflicts: when targeted by multiple deployments a device will use the one with highest priority or (in case of two deployments with the same priority) latest creation time.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "deviceOption", - "type": "pickList", - "label": "Choose single/multiple device", - "required": true, - "options": { - "Single Device": "Single Device", - "Multiple Devices": "Multiple Devices" - }, - "helpMarkDown": "Choose to deploy to single or multiple(by tags) devices", - "visibleRule": "action == Deploy to IoT Edge devices" - }, - { - "name": "deviceId", - "type": "string", - "label": "IoT Edge device ID", - "required": true, - "visibleRule": "deviceOption == Single Device", - "helpMarkDown": "Input the IoT Edge **device ID**" - }, - { - "name": "targetcondition", - "type": "string", - "label": "IoT Edge device target condition", - "required": true, - "visibleRule": "deviceOption == Multiple Devices", - "helpMarkDown": "Input the **target condition** of devices you would like to deploy. Do not use double quote. Example: **tags.building=9 and tags.environment='test'**.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)" - }, - { - "name": "containerregistrytype", - "type": "pickList", - "label": "Container registry type", - "defaultValue": "Azure Container Registry", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "Azure Container Registry": "Azure Container Registry", - "Generic Container Registry": "Generic Container Registry" - }, - "helpMarkDown": "Select a **Container Registry Type**.\n **Azure Container Registry** for ACR and **Generic Container Registry** for generic registries including docker hub." - }, - { - "name": "dockerRegistryEndpoint", - "aliases": [ - "dockerRegistryConnection" - ], - "type": "connectedService:dockerregistry", - "required": true, - "label": "Docker Registry Connection", - "helpMarkDown": "Select a generic **Docker registry connection**. Required for **Build and Push**.", - "visibleRule": "containerregistrytype = Generic Container Registry" - }, - { - "name": "azureSubscriptionEndpoint", - "type": "connectedService:AzureRM", - "label": "Azure subscription", - "helpMarkDown": "Select an Azure subscription", - "visibleRule": "containerregistrytype = Azure Container Registry" - }, - { - "name": "azureContainerRegistry", - "label": "Azure Container Registry", - "type": "pickList", - "required": true, - "helpMarkDown": "Select an **Azure Container Registry**", - "visibleRule": "containerregistrytype = Azure Container Registry", - "defaultValue": "" - }, - { - "name": "templateFilePath", - "type": "filePath", - "label": ".template.json file", - "defaultValue": "deployment.template.json", - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "required": true, - "helpMarkDown": "The path of Azure IoT Edge solution **.template.json**. This file defines the modules and routes in Azure IoT Edge solution, file name must end with **.template.json**" - }, - { - "name": "defaultPlatform", - "type": "pickList", - "label": "Default platform", - "defaultValue": "amd64", - "required": true, - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "options": { - "amd64": "amd64", - "windows-amd64": "windows-amd64", - "arm32v7": "arm32v7" - }, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "In your **.template.json**, you can leave the modules platform unspecified. For these modules, the **default platform** will be used." - }, - { - "name": "fillRegistryCredential", - "type": "pickList", - "label": "Add registry credential to deployment manifest", - "defaultValue": "true", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "true": "true", - "false": "false" - }, - "helpMarkDown": "Add registry credential for pushing docker images to deployment manifest" - }, - { - "name": "deploymentManifestOutputPath", - "type": "filePath", - "label": "Output path", - "defaultValue": "$(System.DefaultWorkingDirectory)/config/deployment.json", - "visibleRule": "action == Generate deployment manifest", - "required": true, - "helpMarkDown": "The output path of generated deployment manifest" - }, - { - "name": "bypassModules", - "type": "string", - "label": "Bypass module(s)", - "defaultValue": "", - "helpMarkDown": "Select the module(s) that you **DO NOT** need to build(or push) in the .template.json, specify module names and separate with comma.\n Example: if you have 2 modules **SampleModule1,SampleModule2** in your .template.json, you want to just build or push **SampleModule1**, then you set the bypass modules as **SampleModule2**. Leave empty if you would like to build all the modules in .template.json.", - "groupName": "advanced_push" - } - ], - "dataSourceBindings": [ - { - "target": "azureContainerRegistry", - "endpointId": "$(azureSubscriptionEndpoint)", - "dataSourceName": "AzureRMContainerRegistries", - "resultTemplate": "{\"Value\":\"{\\\"loginServer\\\":\\\"{{{properties.loginServer}}}\\\", \\\"id\\\" : \\\"{{{id}}}\\\"}\",\"DisplayValue\":\"{{{name}}}\"}" - }, - { - "target": "iothubname", - "endpointId": "$(connectedServiceNameARM)", - "endpointUrl": "{{{endpoint.url}}}/subscriptions/{{{endpoint.subscriptionId}}}/providers/Microsoft.Devices/IotHubs?api-version=2018-04-01", - "resultSelector": "jsonpath:$.value[*].name" - } - ], - "execution": { - "Node": { - "target": "index.js" - } - }, - "messages": { - "BuildingModules": "Building module images...", - "BuildingModulesFinished": "Finished building module images", - "PushingModules": "Pushing module images...", - "PushingModulesFinished": "Finished pushing module images", - "StartDeploy": "Start deploying...", - "FinishDeploy": "Finished Deploying", - "DeploymentFilePath": "The generated deployment file located in the path: %s", - "ExpandingRegistryCredentials": "Expanding registry credentials in deployment file...", - "ReplaceCredential": "Replace credential: %s", - "DeployTaskRunningInBuild": "Deployment task is running in build pipeline? %s", - "CheckValidJson": "Checking if the following file is a valid json: %s", - "Invalid": "Invalid", - "Valid": "Valid", - "NomralizedDeployementId": "Normalized deployment id is: %s", - "DependencyAlreadyInstalled": "%s already installed with version: %s", - "DependencyInstallSuccess": "%s installed with version: %s", - "DependencyInstallFail": "%s installation failed, see detailed error in debug mode", - "TemplateFileInvalid": "The path of template file is not valid: %s", - "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", - "DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", - "ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", - "AzureSdkNotFound": "Azure SDK not found", - "RootPathNotExist": "The Root path %s does not exist", - "SkipModuleImageValidation": "SKIP_MODULE_IMAGE_VALIDATION set to true, skipping module image validation.", - "InvalidRegistryCredentialWarning": "Failed to login %s with given credential. %s", - "CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", - "StartGenerateDeploymentManifest": "Start generating deployment manifest...", - "FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", - "LoginRegistrySucess": "Successfully logged in to registry $s" - }, - "OutputVariables": [ - { - "name": "DEPLOYMENT_FILE_PATH", - "description": "This is the path of generated deployment file.", - "visibleRule": "action = Build module images" - } - ] -} \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/task_REMOTE_14864.json b/Tasks/AzureIoTEdgeV2/task_REMOTE_14864.json deleted file mode 100644 index 09bcdaa6991e..000000000000 --- a/Tasks/AzureIoTEdgeV2/task_REMOTE_14864.json +++ /dev/null @@ -1,268 +0,0 @@ -{ - "id": "80F3F6A0-82A6-4A22-BA7A-E5B8C541B9B8", - "name": "AzureIoTEdge", - "friendlyName": "Azure IoT Edge", - "description": "Build and deploy an Azure IoT Edge image", - "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/build/azure-iot-edge", - "helpMarkDown": "Visit the [documentation](https://aka.ms/azure-iot-edge-ci-cd-docs) for help", - "category": "Build", - "visibility": [ - "Build", - "Release" - ], - "author": "Microsoft Corporation", - "version": { - "Major": 2, - "Minor": 1, - "Patch": 5 - }, - "preview": true, - "instanceNameFormat": "Azure IoT Edge - $(action)", - "groups": [ - { - "name": "advanced_push", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Push module images" - }, - { - "name": "advanced_deploy", - "displayName": "Advanced", - "isExpanded": false, - "visibleRule": "action = Deploy to IoT Edge devices" - } - ], - "inputs": [ - { - "name": "action", - "type": "pickList", - "label": "Action", - "defaultValue": "Build module images", - "required": true, - "options": { - "Build module images": "Build module images", - "Push module images": "Push module images", - "Generate deployment manifest": "Generate deployment manifest", - "Deploy to IoT Edge devices": "Deploy to IoT Edge devices" - }, - "helpMarkDown": "Select an Azure IoT Edge action.\n **Build module images** will only build modules (You can use it to check compilation error).\n **Push module images** will push modules to container registry.\n **Deploy to IoT Edge devices** will deploy the generated deployment file to IoT Hub. (We recommend to put **Deploy** task in release pipeline)." - }, - { - "name": "deploymentFilePath", - "type": "filePath", - "label": "Deployment file", - "defaultValue": "$(System.DefaultWorkingDirectory)/**/*.json", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the deployment json file.\n If this task is in **release pipeline**, you need to set the location of deployment file in artifact.(The default value works for most conditions).\n If this task is in **build pipeline**, you need to set it to the path of **Path of output deployment file**." - }, - { - "name": "connectedServiceNameARM", - "aliases": [ - "azureSubscription" - ], - "type": "connectedService:AzureRM", - "label": "Azure subscription contains IoT Hub", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select an **Azure subscription** that contains IoT Hub" - }, - { - "name": "iothubname", - "type": "pickList", - "label": "IoT Hub name", - "required": true, - "visibleRule": "action == Deploy to IoT Edge devices", - "helpMarkDown": "Select the **IoT Hub**" - }, - { - "name": "deploymentid", - "type": "string", - "label": "IoT Edge deployment ID", - "required": true, - "defaultValue": "$(System.TeamProject)-devops-deployment", - "helpMarkDown": "Input the **IoT Edge Deployment ID**, if ID exists, it will be overridden.\n Up to 128 lowercase letters, numbers and the following characters are allowed [ -:+%_#*?!(),=@;' ].\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "priority", - "type": "string", - "label": "IoT Edge deployment priority", - "required": true, - "defaultValue": "0", - "helpMarkDown": "Set the **priority** to a positive integer to resolve deployment conflicts: when targeted by multiple deployments a device will use the one with highest priority or (in case of two deployments with the same priority) latest creation time.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)", - "groupName": "advanced_deploy" - }, - { - "name": "deviceOption", - "type": "pickList", - "label": "Choose single/multiple device", - "required": true, - "options": { - "Single Device": "Single Device", - "Multiple Devices": "Multiple Devices" - }, - "helpMarkDown": "Choose to deploy to single or multiple(by tags) devices", - "visibleRule": "action == Deploy to IoT Edge devices" - }, - { - "name": "deviceId", - "type": "string", - "label": "IoT Edge device ID", - "required": true, - "visibleRule": "deviceOption == Single Device", - "helpMarkDown": "Input the IoT Edge **device ID**" - }, - { - "name": "targetcondition", - "type": "string", - "label": "IoT Edge device target condition", - "required": true, - "visibleRule": "deviceOption == Multiple Devices", - "helpMarkDown": "Input the **target condition** of devices you would like to deploy. Do not use double quote. Example: **tags.building=9 and tags.environment='test'**.\n Check more information for [Azure IoT Edge deployment](https://docs.microsoft.com/azure/iot-edge/how-to-deploy-monitor#monitor-a-deployment)" - }, - { - "name": "containerregistrytype", - "type": "pickList", - "label": "Container registry type", - "defaultValue": "Azure Container Registry", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "Azure Container Registry": "Azure Container Registry", - "Generic Container Registry": "Generic Container Registry" - }, - "helpMarkDown": "Select a **Container Registry Type**.\n **Azure Container Registry** for ACR and **Generic Container Registry** for generic registries including docker hub." - }, - { - "name": "dockerRegistryEndpoint", - "aliases": [ - "dockerRegistryConnection" - ], - "type": "connectedService:dockerregistry", - "required": true, - "label": "Docker Registry Connection", - "helpMarkDown": "Select a generic **Docker registry connection**. Required for **Build and Push**.", - "visibleRule": "containerregistrytype = Generic Container Registry" - }, - { - "name": "azureSubscriptionEndpoint", - "type": "connectedService:AzureRM", - "label": "Azure subscription", - "helpMarkDown": "Select an Azure subscription", - "visibleRule": "containerregistrytype = Azure Container Registry" - }, - { - "name": "azureContainerRegistry", - "label": "Azure Container Registry", - "type": "pickList", - "required": true, - "helpMarkDown": "Select an **Azure Container Registry**", - "visibleRule": "containerregistrytype = Azure Container Registry", - "defaultValue": "" - }, - { - "name": "templateFilePath", - "type": "filePath", - "label": ".template.json file", - "defaultValue": "deployment.template.json", - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "required": true, - "helpMarkDown": "The path of Azure IoT Edge solution **.template.json**. This file defines the modules and routes in Azure IoT Edge solution, file name must end with **.template.json**" - }, - { - "name": "defaultPlatform", - "type": "pickList", - "label": "Default platform", - "defaultValue": "amd64", - "required": true, - "visibleRule": "action = Build module images || action = Push module images || action = Generate deployment manifest", - "options": { - "amd64": "amd64", - "windows-amd64": "windows-amd64", - "arm32v7": "arm32v7" - }, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "In your **.template.json**, you can leave the modules platform unspecified. For these modules, the **default platform** will be used." - }, - { - "name": "fillRegistryCredential", - "type": "pickList", - "label": "Add registry credential to deployment manifest", - "defaultValue": "true", - "required": true, - "visibleRule": "action = Push module images", - "options": { - "true": "true", - "false": "false" - }, - "helpMarkDown": "Add registry credential for pushing docker images to deployment manifest" - }, - { - "name": "bypassModules", - "type": "string", - "label": "Bypass module(s)", - "defaultValue": "", - "helpMarkDown": "Select the module(s) that you **DO NOT** need to build(or push) in the .template.json, specify module names and separate with comma.\n Example: if you have 2 modules **SampleModule1,SampleModule2** in your .template.json, you want to just build or push **SampleModule1**, then you set the bypass modules as **SampleModule2**. Leave empty if you would like to build all the modules in .template.json.", - "groupName": "advanced_push" - } - ], - "dataSourceBindings": [ - { - "target": "azureContainerRegistry", - "endpointId": "$(azureSubscriptionEndpoint)", - "dataSourceName": "AzureRMContainerRegistries", - "resultTemplate": "{\"Value\":\"{\\\"loginServer\\\":\\\"{{{properties.loginServer}}}\\\", \\\"id\\\" : \\\"{{{id}}}\\\"}\",\"DisplayValue\":\"{{{name}}}\"}" - }, - { - "target": "iothubname", - "endpointId": "$(connectedServiceNameARM)", - "endpointUrl": "{{{endpoint.url}}}/subscriptions/{{{endpoint.subscriptionId}}}/providers/Microsoft.Devices/IotHubs?api-version=2018-04-01", - "resultSelector": "jsonpath:$.value[*].name" - } - ], - "execution": { - "Node": { - "target": "index.js" - } - }, - "messages": { - "BuildingModules": "Building module images...", - "BuildingModulesFinished": "Finished building module images", - "PushingModules": "Pushing module images...", - "PushingModulesFinished": "Finished pushing module images", - "StartDeploy": "Start deploying...", - "FinishDeploy": "Finished Deploying", - "DeploymentFilePath": "The generated deployment file located in the path: %s", - "ExpandingRegistryCredentials": "Expanding registry credentials in deployment file...", - "ReplaceCredential": "Replace credential: %s", - "DeployTaskRunningInBuild": "Deployment task is running in build pipeline? %s", - "CheckValidJson": "Checking if the following file is a valid json: %s", - "Invalid": "Invalid", - "Valid": "Valid", - "NomralizedDeployementId": "Normalized deployment id is: %s", - "DependencyAlreadyInstalled": "%s already installed with version: %s", - "DependencyInstallSuccess": "%s installed with version: %s", - "DependencyInstallFail": "%s installation failed, see detailed error in debug mode", - "TemplateFileInvalid": "The path of template file is not valid: %s", - "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The token is %s", - "DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", - "ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", - "AzureSdkNotFound": "Azure SDK not found", - "RootPathNotExist": "The Root path %s does not exist", - "SkipModuleImageValidation": "SKIP_MODULE_IMAGE_VALIDATION set to true, skipping module image validation.", - "InvalidRegistryCredentialWarning": "Failed to login %s with given credential. %s", - "CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", - "StartGenerateDeploymentManifest": "Start generating deployment manifest...", - "FinishGenerateDeploymentManifest": "Finished generating deployment manifest." - }, - "OutputVariables": [ - { - "name": "DEPLOYMENT_FILE_PATH", - "description": "This is the path of generated deployment file.", - "visibleRule": "action = Build module images" - } - ] -} \ No newline at end of file From f19324d072274c3a48116278353c087b16350643 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Mon, 10 Jun 2019 11:18:45 +0800 Subject: [PATCH 06/11] resolve comments --- .../resources.resjson/en-US/resources.resjson | 5 +++- Tasks/AzureIoTEdgeV2/buildimage.ts | 10 +------ Tasks/AzureIoTEdgeV2/genconfig.ts | 20 +++++-------- Tasks/AzureIoTEdgeV2/pushimage.ts | 10 +------ Tasks/AzureIoTEdgeV2/task.json | 5 +++- Tasks/AzureIoTEdgeV2/task.loc.json | 5 +++- Tasks/AzureIoTEdgeV2/util.ts | 28 +++++++++++++------ 7 files changed, 40 insertions(+), 43 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson index c05315df4222..b66ac9a62083 100644 --- a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson @@ -69,5 +69,8 @@ "loc.messages.CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", "loc.messages.StartGenerateDeploymentManifest": "Start generating deployment manifest...", "loc.messages.FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", - "loc.messages.LoginRegistrySucess": "Successfully logged in to registry $s" + "loc.messages.LoginRegistrySucess": "Successfully logged in to registry %s", + "loc.messages.SkipSettingEnvironmentVariable": "The environment variable %s already exists. Skip setting this environment variable.", + "loc.messages.SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s.", + "loc.messages.OverrideDeploymentManifestOutputPath": "The %s environment variable will be overriden by the output path parameter." } \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/buildimage.ts b/Tasks/AzureIoTEdgeV2/buildimage.ts index 0336e322a81c..7a4d8cff05ec 100644 --- a/Tasks/AzureIoTEdgeV2/buildimage.ts +++ b/Tasks/AzureIoTEdgeV2/buildimage.ts @@ -21,15 +21,7 @@ export async function run() { util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, tl.getVariable(Constants.outputFileFolder)); // Pass task variable to sub process - let tlVariables = tl.getVariables(); - for (let v of tlVariables) { - // The variables in VSTS build contains dot, need to convert to underscore. - if (v.secret) { - let envName = v.name.replace('.', '_').toUpperCase(); - tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); - util.setEnvrionmentVarialbe(envList, envName, v.value); - } - } + util.populateSecretToEnvironmentVariable(envList); tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); diff --git a/Tasks/AzureIoTEdgeV2/genconfig.ts b/Tasks/AzureIoTEdgeV2/genconfig.ts index e5bf4861a928..6e9f2952d5d9 100644 --- a/Tasks/AzureIoTEdgeV2/genconfig.ts +++ b/Tasks/AzureIoTEdgeV2/genconfig.ts @@ -20,25 +20,19 @@ export async function run() { let outputFileName = path.basename(outputPath); let envList = process.env; + if (envList[Constants.iotedgedevEnv.deploymentFileOutputFolder]) { + tl.loc("OverrideDeploymentManifestOutputPath", Constants.iotedgedevEnv.deploymentFileOutputFolder); + } tl.debug(`Setting deployment manifest output folder to ${outputFileFolder}`); util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, outputFileFolder); + if (envList[Constants.iotedgedevEnv.deploymentFileOutputName]) { + tl.loc("OverrideDeploymentManifestOutputPath", Constants.iotedgedevEnv.deploymentFileOutputName); + } tl.debug(`Setting deployment manifest output file name to ${outputFileName}`) util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputName, outputFileName) // Pass task variable to sub process - let tlVariables = tl.getVariables(); - for (let v of tlVariables) { - // The variables in VSTS build contains dot, need to convert to underscore. - if (v.secret){ - let envName = v.name.replace('.', '_').toUpperCase(); - tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); - if (!envList[envName]) { - envList[envName] = v.value; - } else { - tl.warning(`Environment variable ${envName} already exist. Skip setting environment varialbe for secret: ${v.name}.`); - } - } - } + util.populateSecretToEnvironmentVariable(envList); let execOptions: IExecOptions = { cwd: tl.cwd(), diff --git a/Tasks/AzureIoTEdgeV2/pushimage.ts b/Tasks/AzureIoTEdgeV2/pushimage.ts index 60c399a7bc3e..084b2460b8d7 100644 --- a/Tasks/AzureIoTEdgeV2/pushimage.ts +++ b/Tasks/AzureIoTEdgeV2/pushimage.ts @@ -63,15 +63,7 @@ export async function run() { util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryPassword, registryAuthenticationToken.password); // Pass task variable to sub process - let tlVariables = tl.getVariables(); - for (let v of tlVariables) { - // The variables in VSTS build contains dot, need to convert to underscore. - if (v.secret) { - let envName = v.name.replace('.', '_').toUpperCase(); - tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); - util.setEnvrionmentVarialbe(envList, envName, v.value); - } - } + util.populateSecretToEnvironmentVariable(envList); tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index 373ca2c6c440..1457d113f4bd 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -267,7 +267,10 @@ "CheckModuleImageExistenceError": "%s does not exist or the credential is not set correctly. Error: %s", "StartGenerateDeploymentManifest": "Start generating deployment manifest...", "FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", - "LoginRegistrySucess": "Successfully logged in to registry $s" + "LoginRegistrySucess": "Successfully logged in to registry %s", + "SkipSettingEnvironmentVariable": "The environment variable %s already exists. Skip setting this environment variable.", + "SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s.", + "OverrideDeploymentManifestOutputPath": "The %s environment variable will be overriden by the output path parameter." }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index 4a015ab68cf0..3eaa37da46b3 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -267,7 +267,10 @@ "CheckModuleImageExistenceError": "ms-resource:loc.messages.CheckModuleImageExistenceError", "StartGenerateDeploymentManifest": "ms-resource:loc.messages.StartGenerateDeploymentManifest", "FinishGenerateDeploymentManifest": "ms-resource:loc.messages.FinishGenerateDeploymentManifest", - "LoginRegistrySucess": "ms-resource:loc.messages.LoginRegistrySucess" + "LoginRegistrySucess": "ms-resource:loc.messages.LoginRegistrySucess", + "SkipSettingEnvironmentVariable": "ms-resource:loc.messages.SkipSettingEnvironmentVariable", + "SkipSettingEnvironmentVariableForSecret": "ms-resource:loc.messages.SkipSettingEnvironmentVariableForSecret", + "OverrideDeploymentManifestOutputPath": "ms-resource:loc.messages.OverrideDeploymentManifestOutputPath" }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/util.ts b/Tasks/AzureIoTEdgeV2/util.ts index accf8d3c4418..c17954ffc5c6 100644 --- a/Tasks/AzureIoTEdgeV2/util.ts +++ b/Tasks/AzureIoTEdgeV2/util.ts @@ -226,18 +226,28 @@ export default class Util { return true; } - public static setEnvrionmentVarialbe(envList: NodeJS.ProcessEnv, envName: string, envValue: string, overrideExisting: boolean = false): void { + public static setEnvrionmentVarialbe(envList: NodeJS.ProcessEnv, envName: string, envValue: string): void { if (envList[envName]) { - if (overrideExisting) { - tl.warning(`The environment variable ${envName} already exists and will be overrided with the new value.`); - envList[envName] = envValue; + tl.loc("SkipSettingEnvironmentVariable", envName); return; - } else { - tl.warning(`The environment variable ${envName} already exists so will no been overrided.`) - return; - } } - tl.debug(`Setting the valud of environment variable ${envName}`); + tl.debug(`Setting the value of environment variable ${envName}`); envList[envName] = envValue; } + + public static populateSecretToEnvironmentVariable(envList: NodeJS.ProcessEnv){ + let tlVariables = tl.getVariables(); + for (let v of tlVariables) { + // The variables in VSTS build contains dot, need to convert to underscore. + if (v.secret){ + let envName = v.name.replace('.', '_').toUpperCase(); + tl.debug(`Setting environment varialbe ${envName} to the value of secret: ${v.name}`); + if (!envList[envName]) { + envList[envName] = v.value; + } else { + tl.loc("SkipSettingEnvironmentVariableForSecret", envName, v.name); + } + } + } + } } \ No newline at end of file From 602394f8195e4b26bb022e92f81ac688c8bfd7c9 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Mon, 10 Jun 2019 13:13:41 +0800 Subject: [PATCH 07/11] resolve comments --- .../resources.resjson/en-US/resources.resjson | 3 +-- Tasks/AzureIoTEdgeV2/buildimage.ts | 2 +- Tasks/AzureIoTEdgeV2/genconfig.ts | 15 +++++++++++---- Tasks/AzureIoTEdgeV2/pushimage.ts | 4 +++- Tasks/AzureIoTEdgeV2/task.json | 3 +-- Tasks/AzureIoTEdgeV2/task.loc.json | 3 +-- Tasks/AzureIoTEdgeV2/util.ts | 3 +-- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson index b66ac9a62083..474281c08108 100644 --- a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson @@ -70,7 +70,6 @@ "loc.messages.StartGenerateDeploymentManifest": "Start generating deployment manifest...", "loc.messages.FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", "loc.messages.LoginRegistrySucess": "Successfully logged in to registry %s", - "loc.messages.SkipSettingEnvironmentVariable": "The environment variable %s already exists. Skip setting this environment variable.", "loc.messages.SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s.", - "loc.messages.OverrideDeploymentManifestOutputPath": "The %s environment variable will be overriden by the output path parameter." + "loc.messages.DeploymentManifestOutputPathOverridden": "The deployment manifest output path set through variables was overridden by the output path parameter." } \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/buildimage.ts b/Tasks/AzureIoTEdgeV2/buildimage.ts index 7a4d8cff05ec..9311abc0b972 100644 --- a/Tasks/AzureIoTEdgeV2/buildimage.ts +++ b/Tasks/AzureIoTEdgeV2/buildimage.ts @@ -20,7 +20,7 @@ export async function run() { let envList = process.env; util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, tl.getVariable(Constants.outputFileFolder)); - // Pass task variable to sub process + // Pass secrets to sub process util.populateSecretToEnvironmentVariable(envList); tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); diff --git a/Tasks/AzureIoTEdgeV2/genconfig.ts b/Tasks/AzureIoTEdgeV2/genconfig.ts index 6e9f2952d5d9..8b9939789dba 100644 --- a/Tasks/AzureIoTEdgeV2/genconfig.ts +++ b/Tasks/AzureIoTEdgeV2/genconfig.ts @@ -20,18 +20,25 @@ export async function run() { let outputFileName = path.basename(outputPath); let envList = process.env; + //Set output path of iotedgedev genconfig command + let envOverriden = false; if (envList[Constants.iotedgedevEnv.deploymentFileOutputFolder]) { - tl.loc("OverrideDeploymentManifestOutputPath", Constants.iotedgedevEnv.deploymentFileOutputFolder); + tl.debug(`The ${Constants.iotedgedevEnv.deploymentFileOutputFolder} environment varialbe already exists. Will override this environment variable.`); + envOverriden = true; } tl.debug(`Setting deployment manifest output folder to ${outputFileFolder}`); util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, outputFileFolder); if (envList[Constants.iotedgedevEnv.deploymentFileOutputName]) { - tl.loc("OverrideDeploymentManifestOutputPath", Constants.iotedgedevEnv.deploymentFileOutputName); + tl.debug(`The ${Constants.iotedgedevEnv.deploymentFileOutputName} environment varialbe already exists. Will override this environment variable.`); + envOverriden = true; } tl.debug(`Setting deployment manifest output file name to ${outputFileName}`) util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputName, outputFileName) - - // Pass task variable to sub process + if (envOverriden) { + tl.loc("DeploymentManifestOutputPathOverridden"); + } + + // Pass secrets to sub process util.populateSecretToEnvironmentVariable(envList); let execOptions: IExecOptions = { diff --git a/Tasks/AzureIoTEdgeV2/pushimage.ts b/Tasks/AzureIoTEdgeV2/pushimage.ts index 084b2460b8d7..0d263a399814 100644 --- a/Tasks/AzureIoTEdgeV2/pushimage.ts +++ b/Tasks/AzureIoTEdgeV2/pushimage.ts @@ -57,12 +57,14 @@ export async function run() { tl.execSync(`docker`, `login -u "${registryAuthenticationToken.username}" -p "${registryAuthenticationToken.password}" ${registryAuthenticationToken.serverUrl}`, Constants.execSyncSilentOption) let envList = process.env; + // Set bypass modules util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.bypassModules, bypassModules); + // Set registry credentials util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryServer, registryAuthenticationToken.serverUrl); util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryUsername, registryAuthenticationToken.username); util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryPassword, registryAuthenticationToken.password); - // Pass task variable to sub process + // Pass secrets to sub process util.populateSecretToEnvironmentVariable(envList); tl.debug(`Following variables will be passed to the iotedgedev command: ${Object.keys(envList).join(", ")}`); diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index 1457d113f4bd..96f67ca7ee87 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -268,9 +268,8 @@ "StartGenerateDeploymentManifest": "Start generating deployment manifest...", "FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", "LoginRegistrySucess": "Successfully logged in to registry %s", - "SkipSettingEnvironmentVariable": "The environment variable %s already exists. Skip setting this environment variable.", "SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s.", - "OverrideDeploymentManifestOutputPath": "The %s environment variable will be overriden by the output path parameter." + "DeploymentManifestOutputPathOverridden": "The deployment manifest output path set through variables was overridden by the output path parameter." }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index 3eaa37da46b3..fe75e16af198 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -268,9 +268,8 @@ "StartGenerateDeploymentManifest": "ms-resource:loc.messages.StartGenerateDeploymentManifest", "FinishGenerateDeploymentManifest": "ms-resource:loc.messages.FinishGenerateDeploymentManifest", "LoginRegistrySucess": "ms-resource:loc.messages.LoginRegistrySucess", - "SkipSettingEnvironmentVariable": "ms-resource:loc.messages.SkipSettingEnvironmentVariable", "SkipSettingEnvironmentVariableForSecret": "ms-resource:loc.messages.SkipSettingEnvironmentVariableForSecret", - "OverrideDeploymentManifestOutputPath": "ms-resource:loc.messages.OverrideDeploymentManifestOutputPath" + "DeploymentManifestOutputPathOverridden": "ms-resource:loc.messages.DeploymentManifestOutputPathOverridden" }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/util.ts b/Tasks/AzureIoTEdgeV2/util.ts index c17954ffc5c6..6c93fe73202f 100644 --- a/Tasks/AzureIoTEdgeV2/util.ts +++ b/Tasks/AzureIoTEdgeV2/util.ts @@ -228,8 +228,7 @@ export default class Util { public static setEnvrionmentVarialbe(envList: NodeJS.ProcessEnv, envName: string, envValue: string): void { if (envList[envName]) { - tl.loc("SkipSettingEnvironmentVariable", envName); - return; + tl.debug(`The environment variable ${envName} already exists. Will override this environment variable.`) } tl.debug(`Setting the value of environment variable ${envName}`); envList[envName] = envValue; From 533606b384b55b92ca69a6905afe33df2f96cffb Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Mon, 10 Jun 2019 13:29:12 +0800 Subject: [PATCH 08/11] Bump version of iotedgedev to 2.0 to support vs solutions --- Tasks/AzureIoTEdgeV2/constant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/AzureIoTEdgeV2/constant.ts b/Tasks/AzureIoTEdgeV2/constant.ts index 2cc48772788d..56f6d378c4da 100644 --- a/Tasks/AzureIoTEdgeV2/constant.ts +++ b/Tasks/AzureIoTEdgeV2/constant.ts @@ -9,7 +9,7 @@ export default class Constants { public static folderNameConfig = "config"; public static iotedgedev = "iotedgedev"; public static iotedgedevLockVersionKey = "IOTEDGEDEV_VERSION"; - public static iotedgedevDefaultVersion = "1.1.0"; + public static iotedgedevDefaultVersion = "2.0"; public static iotedgedevEnv = { registryServer: "CONTAINER_REGISTRY_SERVER", registryUsername: "CONTAINER_REGISTRY_USERNAME", From 19c724d911faa57bcefbe148bbd89b807fa36665 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Tue, 11 Jun 2019 10:48:11 +0800 Subject: [PATCH 09/11] resolve comment --- .../resources.resjson/en-US/resources.resjson | 3 +-- Tasks/AzureIoTEdgeV2/buildimage.ts | 2 +- Tasks/AzureIoTEdgeV2/genconfig.ts | 16 ++-------------- Tasks/AzureIoTEdgeV2/pushimage.ts | 8 ++++---- Tasks/AzureIoTEdgeV2/task.json | 3 +-- Tasks/AzureIoTEdgeV2/task.loc.json | 3 +-- Tasks/AzureIoTEdgeV2/util.ts | 6 +++--- 7 files changed, 13 insertions(+), 28 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson index 474281c08108..b2eda1af6ab2 100644 --- a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson @@ -70,6 +70,5 @@ "loc.messages.StartGenerateDeploymentManifest": "Start generating deployment manifest...", "loc.messages.FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", "loc.messages.LoginRegistrySucess": "Successfully logged in to registry %s", - "loc.messages.SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s.", - "loc.messages.DeploymentManifestOutputPathOverridden": "The deployment manifest output path set through variables was overridden by the output path parameter." + "loc.messages.SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s." } \ No newline at end of file diff --git a/Tasks/AzureIoTEdgeV2/buildimage.ts b/Tasks/AzureIoTEdgeV2/buildimage.ts index 9311abc0b972..71170da0624a 100644 --- a/Tasks/AzureIoTEdgeV2/buildimage.ts +++ b/Tasks/AzureIoTEdgeV2/buildimage.ts @@ -18,7 +18,7 @@ export async function run() { util.setupIotedgedev(); let envList = process.env; - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, tl.getVariable(Constants.outputFileFolder)); + util.setCliVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, tl.getVariable(Constants.outputFileFolder)); // Pass secrets to sub process util.populateSecretToEnvironmentVariable(envList); diff --git a/Tasks/AzureIoTEdgeV2/genconfig.ts b/Tasks/AzureIoTEdgeV2/genconfig.ts index 8b9939789dba..203b9dbbb6e0 100644 --- a/Tasks/AzureIoTEdgeV2/genconfig.ts +++ b/Tasks/AzureIoTEdgeV2/genconfig.ts @@ -21,22 +21,10 @@ export async function run() { let envList = process.env; //Set output path of iotedgedev genconfig command - let envOverriden = false; - if (envList[Constants.iotedgedevEnv.deploymentFileOutputFolder]) { - tl.debug(`The ${Constants.iotedgedevEnv.deploymentFileOutputFolder} environment varialbe already exists. Will override this environment variable.`); - envOverriden = true; - } tl.debug(`Setting deployment manifest output folder to ${outputFileFolder}`); - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, outputFileFolder); - if (envList[Constants.iotedgedevEnv.deploymentFileOutputName]) { - tl.debug(`The ${Constants.iotedgedevEnv.deploymentFileOutputName} environment varialbe already exists. Will override this environment variable.`); - envOverriden = true; - } + util.setCliVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputFolder, outputFileFolder); tl.debug(`Setting deployment manifest output file name to ${outputFileName}`) - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputName, outputFileName) - if (envOverriden) { - tl.loc("DeploymentManifestOutputPathOverridden"); - } + util.setCliVarialbe(envList, Constants.iotedgedevEnv.deploymentFileOutputName, outputFileName) // Pass secrets to sub process util.populateSecretToEnvironmentVariable(envList); diff --git a/Tasks/AzureIoTEdgeV2/pushimage.ts b/Tasks/AzureIoTEdgeV2/pushimage.ts index 0d263a399814..173383d222bb 100644 --- a/Tasks/AzureIoTEdgeV2/pushimage.ts +++ b/Tasks/AzureIoTEdgeV2/pushimage.ts @@ -58,11 +58,11 @@ export async function run() { let envList = process.env; // Set bypass modules - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.bypassModules, bypassModules); + util.setCliVarialbe(envList, Constants.iotedgedevEnv.bypassModules, bypassModules); // Set registry credentials - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryServer, registryAuthenticationToken.serverUrl); - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryUsername, registryAuthenticationToken.username); - util.setEnvrionmentVarialbe(envList, Constants.iotedgedevEnv.registryPassword, registryAuthenticationToken.password); + util.setCliVarialbe(envList, Constants.iotedgedevEnv.registryServer, registryAuthenticationToken.serverUrl); + util.setCliVarialbe(envList, Constants.iotedgedevEnv.registryUsername, registryAuthenticationToken.username); + util.setCliVarialbe(envList, Constants.iotedgedevEnv.registryPassword, registryAuthenticationToken.password); // Pass secrets to sub process util.populateSecretToEnvironmentVariable(envList); diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index 96f67ca7ee87..b65323f14040 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -268,8 +268,7 @@ "StartGenerateDeploymentManifest": "Start generating deployment manifest...", "FinishGenerateDeploymentManifest": "Finished generating deployment manifest.", "LoginRegistrySucess": "Successfully logged in to registry %s", - "SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s.", - "DeploymentManifestOutputPathOverridden": "The deployment manifest output path set through variables was overridden by the output path parameter." + "SkipSettingEnvironmentVariableForSecret": "Environment variable %s already exist. Skip setting environment varialbe for secret: %s." }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index fe75e16af198..5e983b16fe31 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -268,8 +268,7 @@ "StartGenerateDeploymentManifest": "ms-resource:loc.messages.StartGenerateDeploymentManifest", "FinishGenerateDeploymentManifest": "ms-resource:loc.messages.FinishGenerateDeploymentManifest", "LoginRegistrySucess": "ms-resource:loc.messages.LoginRegistrySucess", - "SkipSettingEnvironmentVariableForSecret": "ms-resource:loc.messages.SkipSettingEnvironmentVariableForSecret", - "DeploymentManifestOutputPathOverridden": "ms-resource:loc.messages.DeploymentManifestOutputPathOverridden" + "SkipSettingEnvironmentVariableForSecret": "ms-resource:loc.messages.SkipSettingEnvironmentVariableForSecret" }, "OutputVariables": [ { diff --git a/Tasks/AzureIoTEdgeV2/util.ts b/Tasks/AzureIoTEdgeV2/util.ts index 6c93fe73202f..d5af5b270c6f 100644 --- a/Tasks/AzureIoTEdgeV2/util.ts +++ b/Tasks/AzureIoTEdgeV2/util.ts @@ -226,11 +226,11 @@ export default class Util { return true; } - public static setEnvrionmentVarialbe(envList: NodeJS.ProcessEnv, envName: string, envValue: string): void { + public static setCliVarialbe(envList: NodeJS.ProcessEnv, envName: string, envValue: string): void { if (envList[envName]) { - tl.debug(`The environment variable ${envName} already exists. Will override this environment variable.`) + tl.debug(`Use parameters from task config and ignore existing variable ${envName}.`) } - tl.debug(`Setting the value of environment variable ${envName}`); + tl.debug(`Setting the value of CLI variable ${envName}`); envList[envName] = envValue; } From ba14fe4e9d757301120b243501b2d2e540659a7d Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Tue, 11 Jun 2019 14:58:52 +0800 Subject: [PATCH 10/11] update task version in telemetry wrapper --- Tasks/AzureIoTEdgeV2/telemetry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/AzureIoTEdgeV2/telemetry.ts b/Tasks/AzureIoTEdgeV2/telemetry.ts index bf4031025368..3ba7201d3c8c 100644 --- a/Tasks/AzureIoTEdgeV2/telemetry.ts +++ b/Tasks/AzureIoTEdgeV2/telemetry.ts @@ -1,7 +1,7 @@ import * as appInsights from 'applicationinsights'; const metadata = { id: 'iot-edge-build-deploy', - version: '2.0.1', + version: '2.2.0', publisher: 'vsc-iot', } From 89bc27d11facee6aa226f625d5dc3e47d18a3c82 Mon Sep 17 00:00:00 2001 From: Chaoyi Yuan Date: Tue, 11 Jun 2019 21:17:56 +0800 Subject: [PATCH 11/11] update loc string name to avoid inconsistent --- .../Strings/resources.resjson/en-US/resources.resjson | 2 +- Tasks/AzureIoTEdgeV2/pushimage.ts | 2 +- Tasks/AzureIoTEdgeV2/task.json | 2 +- Tasks/AzureIoTEdgeV2/task.loc.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson index b2eda1af6ab2..a5f04de2592a 100644 --- a/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureIoTEdgeV2/Strings/resources.resjson/en-US/resources.resjson @@ -59,7 +59,7 @@ "loc.messages.DependencyInstallSuccess": "%s installed with version: %s", "loc.messages.DependencyInstallFail": "%s installation failed, see detailed error in debug mode", "loc.messages.TemplateFileInvalid": "The path of template file is not valid: %s", - "loc.messages.ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", + "loc.messages.InvalidContainerRegistry": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", "loc.messages.DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", "loc.messages.ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", "loc.messages.AzureSdkNotFound": "Azure SDK not found", diff --git a/Tasks/AzureIoTEdgeV2/pushimage.ts b/Tasks/AzureIoTEdgeV2/pushimage.ts index 173383d222bb..31068363f267 100644 --- a/Tasks/AzureIoTEdgeV2/pushimage.ts +++ b/Tasks/AzureIoTEdgeV2/pushimage.ts @@ -24,7 +24,7 @@ function getRegistryAuthenticationToken(): RegistryCredential { if (token != null && token.username != null) { username = token.username; } - throw Error(tl.loc('ContainerRegistryInvalid', username)); + throw Error(tl.loc('InvalidContainerRegistry', username)); } return token; } diff --git a/Tasks/AzureIoTEdgeV2/task.json b/Tasks/AzureIoTEdgeV2/task.json index b65323f14040..fd9c76b632e8 100644 --- a/Tasks/AzureIoTEdgeV2/task.json +++ b/Tasks/AzureIoTEdgeV2/task.json @@ -257,7 +257,7 @@ "DependencyInstallSuccess": "%s installed with version: %s", "DependencyInstallFail": "%s installation failed, see detailed error in debug mode", "TemplateFileInvalid": "The path of template file is not valid: %s", - "ContainerRegistryInvalid": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", + "InvalidContainerRegistry": "Failed to fetch container registry authentication token, please check you container registry setting in build task. The username for container registry is %s", "DeploymentFileNotFound": "Deployment file can't be found. Please ensure Path of deployment file is correctly set in the task.", "ValidDeploymentFileNotFound": "Cannot find a valid deployment file. Please ensure Path of deployment file is correctly set in the task.", "AzureSdkNotFound": "Azure SDK not found", diff --git a/Tasks/AzureIoTEdgeV2/task.loc.json b/Tasks/AzureIoTEdgeV2/task.loc.json index 5e983b16fe31..9148401600a1 100644 --- a/Tasks/AzureIoTEdgeV2/task.loc.json +++ b/Tasks/AzureIoTEdgeV2/task.loc.json @@ -257,7 +257,7 @@ "DependencyInstallSuccess": "ms-resource:loc.messages.DependencyInstallSuccess", "DependencyInstallFail": "ms-resource:loc.messages.DependencyInstallFail", "TemplateFileInvalid": "ms-resource:loc.messages.TemplateFileInvalid", - "ContainerRegistryInvalid": "ms-resource:loc.messages.ContainerRegistryInvalid", + "InvalidContainerRegistry": "ms-resource:loc.messages.InvalidContainerRegistry", "DeploymentFileNotFound": "ms-resource:loc.messages.DeploymentFileNotFound", "ValidDeploymentFileNotFound": "ms-resource:loc.messages.ValidDeploymentFileNotFound", "AzureSdkNotFound": "ms-resource:loc.messages.AzureSdkNotFound",