Closed 574n13y closed 8 months ago
pipeline{ agent any tools{ jdk 'jdk17' terraform 'terraform' } environment { SCANNER_HOME=tool 'sonar-scanner' } stages { stage('clean workspace'){ steps{ cleanWs() } } stage('Checkout from Git'){ steps{ git branch: 'main', url: 'https://github.com/Aj7Ay/TERRAFORM-JENKINS-CICD.git' } } stage('Terraform version'){ steps{ sh 'terraform --version' } } stage("Sonarqube Analysis "){ steps{ withSonarQubeEnv('sonar-server') { sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Terraform \ -Dsonar.projectKey=Terraform ''' } } } stage("quality gate"){ steps { script { waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token' } } } stage('TRIVY FS SCAN') { steps { sh "trivy fs . > trivyfs.txt" } } stage('Excutable permission to userdata'){ steps{ sh 'chmod 777 website.sh' } } stage('Terraform init'){ steps{ sh 'terraform init' } } stage('Terraform plan'){ steps{ sh 'terraform plan' } } stage('Terraform apply'){ steps{ sh 'terraform ${action} --auto-approve' } } } }
Task completed
Let’s create a Job now in Jenkins set a job name and add this pipeline