Step expected in Jenkins Groovy script

Viewed 1245

I am having below groovy script for my Jenkins pipeline. But when running its giving error as step expected where my script already having step. Can anyone suggest what's wrong here..

Script file

pipeline {
agent any
stages {
    stage('Workspace Preparation') {
        steps {
            sh """
                rm -rf ${workspace}/*
            """
        }
    }
   stage('Get Deployment files') {
       steps {
            dir("${workspace}/deployfiles") {
                if("${params.componentType}"=="A") {
                    echo "A component deployment"
                    checkout(## necessary step)
                }
                else if ("${params.componentType}"=="B") {
                    echo "B component deployment"
                    checkout(## necessary step)
                }
                else  {
                    echo "Invalid"
                }


              }
       }
    }
}

}

Getting error as

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 19: Expected a step @ line 14, column 6.
                    if("${params.componentType}"=="A") {
        ^
enter code here
enter code here
1 Answers
Related