-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Built-in trigger #846
Merged
Merged
Add Built-in trigger #846
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bd8daa9
Add built-in trigger resource for project auto releases
denys-octopus ef5492c
Add documentation for built_in_trigger
denys-octopus eedb536
Add tests for built-in trigger
denys-octopus 92ae595
Use value same as returned by the server for tests to avoid "plan is …
denys-octopus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "octopusdeploy_built_in_trigger Resource - terraform-provider-octopusdeploy" | ||
subcategory: "" | ||
description: |- | ||
This resource manages automatic release trigger based on new version of referenced package. | ||
--- | ||
|
||
# octopusdeploy_built_in_trigger (Resource) | ||
|
||
This resource manages automatic release trigger based on new version of referenced package. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "octopusdeploy_project_group" "example" { | ||
name = "Example" | ||
description = "Example Group" | ||
} | ||
|
||
resource "octopusdeploy_project" "example" { | ||
name = "Example" | ||
lifecycle_id = "Lifecycles-101" | ||
project_group_id = octopusdeploy_project_group.example.id | ||
default_guided_failure_mode = "EnvironmentDefault" | ||
default_to_skip_if_already_installed = false | ||
description = "Project with Built-In Trigger" | ||
discrete_channel_release = false | ||
is_disabled = false | ||
is_discrete_channel_release = false | ||
is_version_controlled = false | ||
tenanted_deployment_participation = "Untenanted" | ||
included_library_variable_sets = [] | ||
|
||
connectivity_policy { | ||
allow_deployments_to_no_targets = false | ||
exclude_unhealthy_targets = false | ||
skip_machine_behavior = "SkipUnavailableMachines" | ||
} | ||
} | ||
|
||
resource "octopusdeploy_channel" "example" { | ||
name = "Example Channel" | ||
project_id = octopusdeploy_project.example.id | ||
lifecycle_id = "Lifecycles-101" | ||
} | ||
|
||
data "octopusdeploy_feeds" "built_in" { | ||
feed_type = "BuiltIn" | ||
ids = null | ||
partial_name = "" | ||
skip = 0 | ||
take = 1 | ||
} | ||
|
||
resource "octopusdeploy_deployment_process" "example" { | ||
project_id = octopusdeploy_project.example.id | ||
step { | ||
condition = "Success" | ||
name = "Step One" | ||
package_requirement = "LetOctopusDecide" | ||
start_trigger = "StartAfterPrevious" | ||
run_script_action { | ||
condition = "Success" | ||
is_disabled = false | ||
is_required = true | ||
name = "Action One" | ||
script_body = <<-EOT | ||
$ExtractedPath = $OctopusParameters["Octopus.Action.Package[my.package].ExtractedPath"] | ||
Write-Host $ExtractedPath | ||
EOT | ||
run_on_server = true | ||
|
||
package { | ||
name = "my.package" | ||
package_id = "my.package" | ||
feed_id = data.octopusdeploy_feeds.built_in.feeds[0].id | ||
acquisition_location = "Server" | ||
extract_during_deployment = true | ||
} | ||
} | ||
} | ||
} | ||
|
||
resource "octopusdeploy_built_in_trigger" "example" { | ||
project_id = octopusdeploy_project.example.id | ||
channel_id = octopusdeploy_channel.example.id | ||
|
||
release_creation_package = { | ||
deployment_action = "Action One" | ||
package_reference = "my.package" | ||
} | ||
|
||
depends_on = [ | ||
octopusdeploy_project.example, | ||
octopusdeploy_channel.example, | ||
octopusdeploy_deployment_process.example | ||
] | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `channel_id` (String) The ID of the channel in which triggered release will be created. | ||
- `project_id` (String) The ID of the project the trigger will be attached to. | ||
- `release_creation_package` (Attributes) Combination of deployment action and package references. (see [below for nested schema](#nestedatt--release_creation_package)) | ||
|
||
### Optional | ||
|
||
- `release_creation_package_step_id` (String) The package step ID trigger will be listening. | ||
- `space_id` (String) Space ID of the associated project. | ||
|
||
<a id="nestedatt--release_creation_package"></a> | ||
### Nested Schema for `release_creation_package` | ||
|
||
Optional: | ||
|
||
- `deployment_action` (String) Deployment action. | ||
- `package_reference` (String) Package reference. | ||
|
||
|
84 changes: 84 additions & 0 deletions
84
examples/resources/octopusdeploy_built_in_trigger/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
resource "octopusdeploy_project_group" "example" { | ||
name = "Example" | ||
description = "Example Group" | ||
} | ||
|
||
resource "octopusdeploy_project" "example" { | ||
name = "Example" | ||
lifecycle_id = "Lifecycles-101" | ||
project_group_id = octopusdeploy_project_group.example.id | ||
default_guided_failure_mode = "EnvironmentDefault" | ||
default_to_skip_if_already_installed = false | ||
description = "Project with Built-In Trigger" | ||
discrete_channel_release = false | ||
is_disabled = false | ||
is_discrete_channel_release = false | ||
is_version_controlled = false | ||
tenanted_deployment_participation = "Untenanted" | ||
included_library_variable_sets = [] | ||
|
||
connectivity_policy { | ||
allow_deployments_to_no_targets = false | ||
exclude_unhealthy_targets = false | ||
skip_machine_behavior = "SkipUnavailableMachines" | ||
} | ||
} | ||
|
||
resource "octopusdeploy_channel" "example" { | ||
name = "Example Channel" | ||
project_id = octopusdeploy_project.example.id | ||
lifecycle_id = "Lifecycles-101" | ||
} | ||
|
||
data "octopusdeploy_feeds" "built_in" { | ||
feed_type = "BuiltIn" | ||
ids = null | ||
partial_name = "" | ||
skip = 0 | ||
take = 1 | ||
} | ||
|
||
resource "octopusdeploy_deployment_process" "example" { | ||
project_id = octopusdeploy_project.example.id | ||
step { | ||
condition = "Success" | ||
name = "Step One" | ||
package_requirement = "LetOctopusDecide" | ||
start_trigger = "StartAfterPrevious" | ||
run_script_action { | ||
condition = "Success" | ||
is_disabled = false | ||
is_required = true | ||
name = "Action One" | ||
script_body = <<-EOT | ||
$ExtractedPath = $OctopusParameters["Octopus.Action.Package[my.package].ExtractedPath"] | ||
Write-Host $ExtractedPath | ||
EOT | ||
run_on_server = true | ||
|
||
package { | ||
name = "my.package" | ||
package_id = "my.package" | ||
feed_id = data.octopusdeploy_feeds.built_in.feeds[0].id | ||
acquisition_location = "Server" | ||
extract_during_deployment = true | ||
} | ||
} | ||
} | ||
} | ||
|
||
resource "octopusdeploy_built_in_trigger" "example" { | ||
project_id = octopusdeploy_project.example.id | ||
channel_id = octopusdeploy_channel.example.id | ||
|
||
release_creation_package = { | ||
deployment_action = "Action One" | ||
package_reference = "my.package" | ||
} | ||
|
||
depends_on = [ | ||
octopusdeploy_project.example, | ||
octopusdeploy_channel.example, | ||
octopusdeploy_deployment_process.example | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without that ☝️ , updating of deployment process resource would fail, because new
id
will be generated every time when updating deployment process and because oldid
is referenced by built-in trigger deployment process will prevent to replace it.