-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
57 lines (56 loc) · 1.32 KB
/
Jenkinsfile
File metadata and controls
57 lines (56 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
String d = "docs/tutorials/jenkins/opentofu-kubernetes"
def status = 0
pipeline {
agent any
environment {
KUBE_CONFIG_PATH = credentials('kubeconfig')
TF_VAR_namespace = "terraform-example"
}
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/cicd-tutorials/feedback.git'
}
}
stage('Plan') {
agent { docker {
image 'ghcr.io/opentofu/opentofu:latest'
args '--entrypoint=""'
reuseNode true
} }
steps {
dir("iac/tf") {
sh "tofu init -no-color"
script {
status = sh returnStatus: true, script: "tofu plan -no-color -detailed-exitcode -out ${env.BUILD_TAG}.plan"
}
stash includes: "${env.BUILD_TAG}.plan", name: 'plan'
}
}
}
stage('Apply') {
agent { docker {
image 'ghcr.io/opentofu/opentofu:latest'
args '--entrypoint=""'
reuseNode true
} }
when {
beforeInput true
equals expected: 2, actual: status
}
input {
message 'Apply the plan?'
ok 'Apply'
}
steps {
dir("iac/tf") {
unstash 'plan'
sh """
tofu init -no-color
tofu apply -no-color ${env.BUILD_TAG}.plan
"""
}
}
}
}
}