Skip to content

Commit

Permalink
Add documentation for built_in_trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
denys-octopus committed Dec 27, 2024
1 parent bd8daa9 commit ef5492c
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 0 deletions.
124 changes: 124 additions & 0 deletions docs/resources/built_in_trigger.md
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 examples/resources/octopusdeploy_built_in_trigger/resource.tf
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
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var _ EntitySchema = BuiltInTriggerSchema{}

func (r BuiltInTriggerSchema) GetResourceSchema() resourceSchema.Schema {
return resourceSchema.Schema{
Description: "This resource manages automatic release trigger based on new version of referenced package.",
Attributes: map[string]resourceSchema.Attribute{
"project_id": util.ResourceString().
Description("The ID of the project the trigger will be attached to.").
Expand Down

0 comments on commit ef5492c

Please sign in to comment.