jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
127 stars 55 forks source link

Set terraform output variables as multi-job output pipeline variables #16

Open charleszipp opened 4 years ago

charleszipp commented 4 years ago

Set the pipeline variables generated from terraform output to be accessible across multiple jobs within a stage as documented here.

This would require setting the isOutput=true flag when setting the variable.

Currently the azure-pipelines-task-lib does not provide a means to do this. See this issue. However, if can write the task.setvariable command manually to stdout then this should still be possible.

This should include the TERRAFORM_PLAN_HAS_CHANGES variable produced when running terraform plan with detailed exit code.

FernandoMiguel commented 3 years ago

I'm guessing this is why I'm seeing this?

Evaluating: and(succeeded(), eq(variables['TERRAFORM_PLAN_HAS_CHANGES'], 'true'))
Expanded: and(True, eq(Null, 'true'))
Result: False
FernandoMiguel commented 3 years ago

yeah i saw that. i'll link the code to this ticket and wait it gets fixed before re-enabling

OmnipotentOwl commented 3 years ago

After a quick look into the azure-pipeline-task-lib repo it does look like functionality was added to the setVariable method to allow output variables starting with version 2.12.0 so it should be possible to implement this natively now. Ref: https://github.com/microsoft/azure-pipelines-task-lib/pull/691

charleszipp commented 3 years ago

Thanks for pointing this out @OmnipotentOwl!

DenWin commented 3 years ago

see PR #31

DenWin commented 3 years ago

There would be 2 options - either to add a parameter to switch between variables and outputs - though in that case I would only have one or the other. A better option - in my opinion - would be to use an additional name for the output variables, e.g. to suffix them

dsfrederic commented 2 years ago

It should also be possible to get the output variable of a specific job. For example: I've got a pipeline with multiple generated plans splitted into multiple jobs. AFAIK there's no way to get TERRAFORM_PLAN_HAS_CHANGES from job X.

Michaelvsk commented 2 years ago

That feature has been reverted last year and has not been reimplemented, yet or did I miss any parameter to activate it?

terrymunro commented 1 year ago

Indeed, this would be nice.

I'm resorting to adding a step directly after, that just sets another variable with isOutput=true :(

mdanylyuk commented 1 year ago

Hello, Are there any changes in this question? Realy helpful thing)

jason-johnson commented 1 year ago

This is planned but a workaround is shown here .