Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Opentofu
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DBS
gitlab-component
Opentofu
Commits
3c1ccbd3
Unverified
Commit
3c1ccbd3
authored
1 year ago
by
Timo Furrer
Browse files
Options
Downloads
Patches
Plain Diff
Fix test
parent
a1440f2c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
templates/full-pipeline.yml
+39
-25
39 additions, 25 deletions
templates/full-pipeline.yml
tests/integration-tests/Defaults.gitlab-ci.yml
+14
-0
14 additions, 0 deletions
tests/integration-tests/Defaults.gitlab-ci.yml
tests/integration.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
tests/integration.gitlab-ci.yml
with
55 additions
and
27 deletions
templates/full-pipeline.yml
+
39
−
25
View file @
3c1ccbd3
spec
:
spec
:
inputs
:
inputs
:
# Stages
stage_validate
:
stage_validate
:
default
:
'
validate'
default
:
'
validate'
description
:
'
Defines
the
validate
stage'
description
:
'
Defines
the
validate
stage'
...
@@ -15,30 +16,45 @@ spec:
...
@@ -15,30 +16,45 @@ spec:
stage_cleanup
:
stage_cleanup
:
default
:
'
cleanup'
default
:
'
cleanup'
description
:
'
Defines
the
cleanup
stage'
description
:
'
Defines
the
cleanup
stage'
enable_destroy_job
:
default
:
false
# Versions
description
:
'
Weather
the
destroy
job
should
be
created'
opentofu_version
:
default
:
'
1.6.0'
options
:
-
'
1.6.0'
-
'
1.6.0-rc1'
description
:
'
Released
version
of
upstream
OpenTofu'
# Images
gitlab_opentofu_image
:
default
:
'
$CI_REGISTRY/components/opentofu/gitlab-opentofu-$[[
inputs.opentofu_version
]]'
description
:
'
Image
name
of
the
gitlab-opentofu
image'
# Configuration
root_dir
:
default
:
${CI_PROJECT_DIR}
description
:
'
Root
directory
for
the
OpenTofu
project'
state_name
:
default
:
default
description
:
'
State
name'
---
---
.default
:
.default
:
image
:
image
:
name
:
"
$CI_TEMPLATE_REGISTRY_HOST/gitlab-org/terraform-images/stable:latest"
name
:
$[[ inputs.gitlab_opentofu_image ]]
cache
:
cache
:
key
:
"
$
{TF_ROOT}
"
key
:
"
$
[[
inputs.root_dir
]]
"
paths
:
paths
:
-
${TF_ROOT}/.terraform/
-
$[[ inputs.root_dir ]]/.terraform/
variables
:
TF_ROOT
:
${CI_PROJECT_DIR}
# The relative path to the root directory of the Terraform project
TF_STATE_NAME
:
default
# The name of the state file used by the GitLab Managed Terraform state backend
fmt
:
fmt
:
extends
:
.default
extends
:
.default
stage
:
$[[ inputs.stage_validate ]]
stage
:
$[[ inputs.stage_validate ]]
needs
:
[]
needs
:
[]
script
:
script
:
-
gitlab-
open
tofu fmt
-
gitlab-tofu fmt
allow_failure
:
true
allow_failure
:
true
rules
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
...
@@ -50,7 +66,7 @@ validate:
...
@@ -50,7 +66,7 @@ validate:
extends
:
.default
extends
:
.default
stage
:
$[[ inputs.stage_validate ]]
stage
:
$[[ inputs.stage_validate ]]
script
:
script
:
-
gitlab-
open
tofu validate
-
gitlab-tofu validate
rules
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
...
@@ -61,12 +77,12 @@ plan:
...
@@ -61,12 +77,12 @@ plan:
extends
:
.default
extends
:
.default
stage
:
$[[ inputs.stage_build ]]
stage
:
$[[ inputs.stage_build ]]
script
:
script
:
-
gitlab-
open
tofu plan
-
gitlab-tofu plan
-
gitlab-
open
tofu plan-json
-
gitlab-tofu plan-json
environment
:
environment
:
name
:
$
{TF_STATE_NAME}
name
:
$
[[ inputs.state_name ]]
action
:
prepare
action
:
prepare
resource_group
:
$
{TF_STATE_NAME}
resource_group
:
$
[[ inputs.state_name ]]
artifacts
:
artifacts
:
# Terraform's cache files can include secrets which can be accidentally exposed.
# Terraform's cache files can include secrets which can be accidentally exposed.
# Please exercise caution when utilizing secrets in your Terraform infrastructure and
# Please exercise caution when utilizing secrets in your Terraform infrastructure and
...
@@ -76,9 +92,9 @@ plan:
...
@@ -76,9 +92,9 @@ plan:
# See: https://docs.gitlab.com/ee/ci/yaml/#artifactspublic
# See: https://docs.gitlab.com/ee/ci/yaml/#artifactspublic
public
:
false
public
:
false
paths
:
paths
:
-
$
{TF_ROOT}
/plan.cache
-
$
[[ inputs.root_dir ]]
/plan.cache
reports
:
reports
:
terraform
:
$
{TF_ROOT}
/plan.json
terraform
:
$
[[ inputs.root_dir ]]
/plan.json
rules
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
-
if
:
$CI_OPEN_MERGE_REQUESTS
# Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
...
@@ -89,11 +105,11 @@ apply:
...
@@ -89,11 +105,11 @@ apply:
extends
:
.default
extends
:
.default
stage
:
$[[ inputs.stage_deploy ]]
stage
:
$[[ inputs.stage_deploy ]]
script
:
script
:
-
gitlab-
open
tofu apply
-
gitlab-tofu apply
environment
:
environment
:
name
:
$TF_STATE_NAME
name
:
$TF_STATE_NAME
action
:
start
action
:
start
resource_group
:
$
{TF_STATE_NAME}
resource_group
:
$
[[ inputs.state_name ]]
rules
:
rules
:
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $TF_AUTO_DEPLOY == "true"
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $TF_AUTO_DEPLOY == "true"
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
...
@@ -101,10 +117,8 @@ apply:
...
@@ -101,10 +117,8 @@ apply:
destroy
:
destroy
:
extends
:
.default
extends
:
.default
stage
:
$[[ inputs.stage_
destroy
]]
stage
:
$[[ inputs.stage_
cleanup
]]
script
:
script
:
-
gitlab-
open
tofu destroy
-
gitlab-tofu destroy
resource_group
:
$
{TF_STATE_NAME}
resource_group
:
$
[[ inputs.state_name ]]
when
:
manual
when
:
manual
rules
:
-
if
:
$[[ inputs.enable_destroy_job ]]
This diff is collapsed.
Click to expand it.
tests/integration-tests/Defaults.gitlab-ci.yml
+
14
−
0
View file @
3c1ccbd3
include
:
include
:
-
component
:
gitlab.com/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_SHA
-
component
:
gitlab.com/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_SHA
inputs
:
gitlab_opentofu_image
:
$GITLAB_OPENTOFU_IMAGE_NAME
root_dir
:
$TF_ROOT
state_name
:
$TF_STATE_NAME
stages
:
[
validate
,
test
,
build
,
deploy
,
cleanup
]
# Required to run everything immediately, instead of manually.
apply
:
rules
:
[{
when
:
always
}]
destroy
:
rules
:
[{
when
:
always
}]
This diff is collapsed.
Click to expand it.
tests/integration.gitlab-ci.yml
+
2
−
2
View file @
3c1ccbd3
...
@@ -4,9 +4,9 @@ component:
...
@@ -4,9 +4,9 @@ component:
IMAGE
:
$OPENTOFU_IMAGE_NAME
IMAGE
:
$OPENTOFU_IMAGE_NAME
OPENTOFU_VERSION
:
$STABLE_OPENTOFU_VERSION
OPENTOFU_VERSION
:
$STABLE_OPENTOFU_VERSION
TF_STATE_NAME
:
ci-integration-$CI_PIPELINE_IID-$CI_NODE_INDEX
TF_STATE_NAME
:
ci-integration-$CI_PIPELINE_IID-$CI_NODE_INDEX
TF_ROOT
:
tests
TF_ROOT
:
tests
/terraform
trigger
:
trigger
:
include
:
tests/integration-test/$PIPELINE
include
:
tests/integration-test
s
/$PIPELINE
strategy
:
depend
strategy
:
depend
rules
:
rules
:
-
if
:
'
$CI_PROJECT_PATH
==
"components/opentofu"'
-
if
:
'
$CI_PROJECT_PATH
==
"components/opentofu"'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment