terraform-provider-octopusdeploy
terraform-provider-octopusdeploy copied to clipboard
Enabling Source Control On Project Gets Error But Still Changes Settings As Expected
Describe the bug When migrating a pure UI Octopus project to a project with source control enabled then an error is experienced during the terraform apply step; however, the project settings are updated as described in the terraform plan. This may impact further changes from completing successfully though.
Steps to reproduce
- Make a change like below
# octopusdeploy_project.XXXX will be updated in-place
~ resource "octopusdeploy_project" "XXXX" {
id = "Projects-626"
~ is_version_controlled = false -> true
name = "XXXX"
# (16 unchanged attributes hidden)
+ git_library_persistence_settings {
+ base_path = ".octopus"
+ default_branch = "MY-BRANCH"
+ git_credential_id = "GitCredentials-1"
+ url = "https://bitbucket.org/XXXXX/XXXX.git"
}
# (3 unchanged blocks hidden)
}
- Terraform apply fails with below error
Error: octopus deploy api returned an error on endpoint /api/Spaces-42/projects/Projects-626 - [Cannot update deployment settings for a version controlled project with this endpoint. Please use the '/projects/{projectId}/{gitRef}/deploymentsettings' endpoint instead.]
with octopusdeploy_project.XXXX,
on projects.tf line 1584, in resource "octopusdeploy_project" "XXXX":
1584: resource "octopusdeploy_project" "XXXX" {
Terraform-Configuration-UntestedTerraformCLIVersion: Terraform steps are tested against versions 0.11.15 to <1.1.0 of the Terraform CLI. Version 1.3.5 of Terraform CLI has not been tested, however Terraform commands may work successfully with this version. Click the error code link for more information.
Running rollback behaviours...
The following command: "terraform" apply -no-color -auto-approve
With the working directory of: /home/Octopus/Work/20221205221101-147346-462/staging
Failed with exit code: 1
Error: octopus deploy api returned an error on endpoint /api/Spaces-42/projects/Projects-626 - [Cannot update deployment settings for a version controlled project with this endpoint. Please use the '/projects/{projectId}/{gitRef}/deploymentsettings' endpoint instead.]
with octopusdeploy_project.XXXX,
on projects.tf line 1584, in resource "octopusdeploy_project" "XXXX":
1584: resource "octopusdeploy_project" "XXXX" {
Calamari.Common.Features.Processes.CommandLineException
at Calamari.Common.Features.Processes.CommandResult.VerifySuccess() in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\CommandResult.cs:line 27
at Calamari.Terraform.TerraformCliExecutor.VerifySuccess(CommandResult commandResult, Predicate`1 isSuccess) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Terraform\TerraformCliExecutor.cs:line 151
at Calamari.Terraform.TerraformCliExecutor.VerifySuccess(CommandResult commandResult) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Terraform\TerraformCliExecutor.cs:line 156
at Calamari.Terraform.Behaviours.ApplyBehaviour.Execute(RunningDeployment deployment, Dictionary`2 environmentVariables) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Terraform\Behaviours\ApplyBehaviour.cs:line 32
at Calamari.Terraform.Behaviours.TerraformDeployBehaviour.Execute(RunningDeployment context) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Terraform\Behaviours\TerraformDeployBehaviour.cs:line 55
at Calamari.Common.Plumbing.Pipeline.PipelineCommand.ExecuteBehaviour(RunningDeployment context, IBehaviour behaviour) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Plumbing\Pipeline\PipelineCommand.cs:line 165
at Calamari.Common.Plumbing.Pipeline.PipelineCommand.Execute(ILifetimeScope lifetimeScope, IVariables variables) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Plumbing\Pipeline\PipelineCommand.cs:line 61
at Calamari.Common.Plumbing.Pipeline.PipelineCommand.Execute(ILifetimeScope lifetimeScope, IVariables variables) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Plumbing\Pipeline\PipelineCommand.cs:line 85
at Calamari.Common.CalamariFlavourProgramAsync.Run(String[] args) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\CalamariFlavourProgramAsync.cs:line 128
Expected behavior There should be no error and if error is real then rollback should succeed
Logs and other supporting information Plan and error in above
Screenshots None
Environment and versions:
- OS: Linux
- Octopus Server Version:
2022.4. (Build 8211)
- Terraform Version:
1.3.5
- Octopus Terraform Provider Version:
0.9.2
Additional context Saw the same problems on early versions as well
Potentially related https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy/issues/496
Closed as likely resolved in from https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy/issues/496