I am running one container which have both Jenkins and Terraform. Now I want to execute a simple terraform code which is available at GitHub. Below pipeline is not running. Can you please suggest:
pipeline {
agent { any }
stages {
stage(‘Checkout Code’) {
steps {
git branch: ‘main’, url: ‘GitHub - sharatbhaskar1988/terraformtest’
}
}
stage(‘Run Terraform’) {
steps {
sh ‘./terraform init’
sh ‘terraform plan’
sh ‘./terraform apply’
}
}
}
}
Error:
Started by user admin org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 2: Expected an agent @ line 2, column 3. agent { any } ^ WorkflowScript: 2: No agent type specified. Must be one of [any, label, none] @ line 2, column 3. agent { any } ^ 2 errors at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1107) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox$Scope.parse(GroovySandbox.java:163) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:190) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:175) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:635) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:581) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:335) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:442) Finished: FAILURE