Terraform Running Using Jenkins CI-CD Pipeline
Terraform Running Using Jenkins CI-CD Pipeline
Step1:
[root@localhost ~]#
Step2:
Archive: terraform_1.0.8_linux_amd64.zip
inflating: terraform
[root@localhost ~]#
Step3:
[root@localhost ~]#
Terraform v1.0.8
on linux_amd64
Step4:
Click on available and search button type terraform and github integration ticket click on installwithout restart
Step5:
Give the /usr/bin which we was installed Step 1,2 and 3 than save
Step6:
Click on pipeline
Type
pipeline{
agent any
}
Now I am adding the terraform into pipeline script click on Pipeline Syntax
Copy the above pipeline script and paste in pipeline. I moved the terraform 'terraform' and }
Open pipeline syntax from pipeline job snippet Generator Sample Step git:GitGet github url from ur github and
paste in Repository URL-branch is main-clcik on Add Jenkins (add your github login password)click on credential it will
show your github login password select the login—click on Generate pipeline script
Now I am going add the stage2 terraform init command. First stage then steps
Stage("Terraform Init”){
Steps{
Click on snippet generator sample steps select sh:Shell Script it open shell script type your command is terraform init
Generate pipeline script copy the pipeline script generate for Terraform init paste in pipeline job
I am creating another 3rs stage step for terraform apply auto approve
Click on snippet generator sample steps select sh:Shell Script it open shell script type your command is terraform
apply --auto-approve Generate pipeline script copy the pipeline script generate for terraform apply --auto-approve
paste in pipeline jobsave and apply
Go back to Jenkin Dashboard click on your pipeline project click on build now check the status