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

Pipelines cannot change directory if directory is called stage

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      In the latest version of Jenkins LTS, if you create a pipeline and make Groovy code that changes to a directory called 'stage', "stage", or '''stage''', it will still try and interpret it to a build stage and expect a name argument. If you go dir 'stage' {}, it will complain that you provided a closure to the name argument of a stage command.

      Furthermore (and, I find this even stranger), this Groovy code STILL tries to run stage in the same spot.

      //This occurs with 'stage', "stage", or '''stage'''
      def STG_DIRECTORY = 'stage'
      dir STG_DIRECTORY {
          //Some code
      }
      

        Attachments

          Activity

          Hide
          abayer Andrew Bayer added a comment -

          So the following works fine for me:

          node {
            dir('stage') {
              echo "This works fine"
            }
            def STG_DIRECTORY = 'stage'
            dir(STG_DIRECTORY) {
              echo "Tada"
            }
          }
          

          The lack of parens in your dir STG_DIRECTORY example does cause an error, but that's because you need those parentheses. =)

          Show
          abayer Andrew Bayer added a comment - So the following works fine for me: node { dir( 'stage' ) { echo "This works fine" } def STG_DIRECTORY = 'stage' dir(STG_DIRECTORY) { echo "Tada" } } The lack of parens in your dir STG_DIRECTORY example does cause an error, but that's because you need those parentheses. =)

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              charlestoller Charles Toller
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: