Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50677

Groovy will fail to execute shell via dir()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pipeline
    • None

      I have a pipeline with a very simple set of instructions, as follows:

      dir('front-end') {
         sh 'npm install'
         sh 'ionic android build'
      }

      But if I run it like the code above, it fails mid-compilation. I have already also tried like this:

      sh 'cd front-end/'
      sh 'npm install'
      sh 'ionic android build'

      Also fails (different error though).

       

      The only way I got it working was to put it all together using triple-quotes, like this:

      sh '''\
      cd front-end/
      npm install
      ionic android build
      '''

       

      Why is that?

            Unassigned Unassigned
            cdechery Christian Dechery
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: