Skip to content

Commit

Permalink
v5.2 (#45)
Browse files Browse the repository at this point in the history
- Doesn't handle other Azure Clouds #38
- Task v5 fails if there is no output #25
- Updated dependencies of Azure SDK's
  • Loading branch information
keesschollaart81 authored Sep 15, 2019
1 parent 7e30a83 commit 03aa7d3
Show file tree
Hide file tree
Showing 8 changed files with 4,894 additions and 27 deletions.
8 changes: 3 additions & 5 deletions arm-outputs/arm-outputsV2/arm-outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ export class ArmOutputs {
throw new Error(`Deployment '${deployments[0].name}' of Resource Group '${this.config.resourceGroupName}' did not succeed (status '${deployments[0].properties.provisioningState}')`);
}

var outputs = deployments[0].properties.outputs;
if (!outputs) {
throw new Error(`No output parameters could be found for the deployment '${deployments[0].name}' of Resource Group '${this.config.resourceGroupName}'."`)
}

var results: ArmOutputResult[] = [];

var outputs = deployments[0].properties.outputs;

for (var output in outputs) {

if (this.config.outputNames.length > 0 && !this.config.outputNames.some(x => x.trim() == output)) {
Expand Down
28 changes: 18 additions & 10 deletions arm-outputs/arm-outputsV2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export class AzureDevOpsArmOutputsTaskHost {
let success = true;

try {
const debugModeString: string = tl.getVariable('System.Debug');
const debugMode: boolean = debugModeString ? debugModeString.toLowerCase() != 'false' : false;
if (debugMode) {
tl.warning("You are running in debug mode (variable System.Debug is set to true), the values of your ARM Outputs will be printed to the log. If your deployment outputs any secret values, they will be shown, be careful (especially with public projects)!");
}

let connectedServiceNameARM: string = tl.getInput("ConnectedServiceNameARM");
var endpointAuth = tl.getEndpointAuthorization(connectedServiceNameARM, true);
var authScheme = tl.getEndpointAuthorizationScheme(connectedServiceNameARM, true);
Expand All @@ -30,12 +36,6 @@ export class AzureDevOpsArmOutputsTaskHost {

if (!prefix || prefix == "null") prefix = "";

const debugModeString: string = tl.getVariable('System.Debug');
const debugMode: boolean = debugModeString ? debugModeString.toLowerCase() != 'false' : false;
if (debugMode) {
tl.warning("You are running in debug mode (variable System.Debug is set to true), the values of your ARM Outputs will be printed to the log. If your deployment outputs any secret values, they will be shown, be careful (especially with public projects)!");
}

var params = <ArmOutputParams>{
tokenCredentials: credentials,
subscriptionId: subscriptionId,
Expand All @@ -48,10 +48,15 @@ export class AzureDevOpsArmOutputsTaskHost {

var armOutputs = new ArmOutputs(params);
var outputs = await armOutputs.run();
outputs.forEach(output => {
console.info(`Updating Azure Pipelines variable '${output.key}'`);
tl.setVariable(output.key, output.value, false);
});

if (outputs && outputs.length == 0) {
tl.warning(`No output parameters could be found for the deployment`);
} else {
outputs.forEach(output => {
console.info(`Updating Azure Pipelines variable '${output.key}'`);
tl.setVariable(output.key, output.value, false);
});
}
}
catch (err) {
console.error("Unhandled exception during ARM Outputs Task", err);
Expand Down Expand Up @@ -98,12 +103,15 @@ export class AzureDevOpsArmOutputsTaskHost {
}

private getEnvironment = (environmentName: string): msrestAzure.AzureEnvironment => {
if (!environmentName) return msrestAzure.AzureEnvironment.Azure;

const azureEnvironmentMaps = {
azurechinacloud: msrestAzure.AzureEnvironment.AzureChina,
azurecloud: msrestAzure.AzureEnvironment.Azure,
azuregermancloud: msrestAzure.AzureEnvironment.AzureGermanCloud,
azureusgovernment: msrestAzure.AzureEnvironment.AzureUSGovernment,
};

return azureEnvironmentMaps[environmentName.toLowerCase()];
}
}
Expand Down
Loading

0 comments on commit 03aa7d3

Please sign in to comment.