Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError: No such DSL method 'bash' found among steps

I want to run bash commands throw Jenkins pipeline, I'm calling a function that has some bash commands but I'm getting this error:

 java.lang.NoSuchMethodError: No such DSL method 'bash' found among steps 

This is the function:

def copy_tools(){

   // tools
   bash '''#!/bin/bash
   mkdir X6//CX6
   cp ${x6_tools_path} .
   unzip CX6.zip -d .\\X6
   '''

}

can you please help?

like image 307
Atheel Massalha Avatar asked Nov 20 '17 08:11

Atheel Massalha


1 Answers

You want to use sh, not bash. You aren't directly running bash in your code. You need to run the sh pipeline step, which will run the configured shell.

def copy_tools(){

   // tools
   sh '''#!/bin/bash
   mkdir X6//CX6
   cp ${x6_tools_path} .
   unzip CX6.zip -d .\\X6
   '''
}
like image 74
Rob Hales Avatar answered Oct 22 '22 13:10

Rob Hales