0

I have installed jenkins in windows machine, and i configured environment variable as well. When i am checking ant -version in cmd i can able to get the response from the terminal "Apache Ant version 1.7.1 compiled on June 27 2008".

Jenkins Configuration

Ant plugin installed. Ant home configured in jenkins

Ant config in jenkins

I am checking ant -version in pipeline script, but i am getting build failed in jenkins with following error message "ant' is not recognized as an internal or external command"

stage('studio'){
          steps { 
                bat 'ant -version'
            }
      }

Can you please someone help on this issue.

Anji
  • 63
  • 2
  • 8

1 Answers1

0

You are mssing some details in the construction .. bat does not know about ant. See How to invoke Ant in a Jenkins Groovy Pipeline

def antVersion = 'Ant1.9.1'
withEnv( ["ANT_HOME=${tool antVersion}"] ) {
      bat '%ANT_HOME%/bin/ant.bat target1 target2'`
}

Also, don't name it ANT_HOME, but something relevant like ant-1.7.1

Ian W
  • 4,559
  • 2
  • 18
  • 37