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

Viewed 4261

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?

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
   '''
}
Related