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

Add option to fail build if unshelve changelist does not exists

    XMLWordPrintable

Details

    Description

      I'd like to request adding an option the the Perforce: Unshelve build step to fail the build if the unshelve changelist does not exist.

      Perhaps a checkbox with "Fail build if unshelve changelist does not exist"

      Currently the console output looks like this when unshelving using a shelve list that does not exists.

       

        p4 unshelve -f -s252595 -cdefault

        No such file(s).

       

      For our workflow it would be an error for the build to pass if there were no shelved files.

      Attachments

        Activity

          p4karl Karl Wirth added a comment -

          Hi totsubo,

          I just tried this with a basic Freestyle job and it does fail the build:

          P4 Task: unshelve review: 999999
          ... p4 unshelve -f -s999999 -cdefault +
          P4JAVA: Change 999999 unknown.
          
          P4 Task: attempt: 1
          Build step 'Perforce: Unshelve' marked build as failure
          Finished: FAILURE
          

          Therefore please can you provide more context:

          • What type of job is this (FreeStyle, Pipeline, MultiBranch)
          • Please provide the Jenkinsfile, Groovy code or a screenshot of the step (if Freestlye) that you run that uses unshelve.
          • What version of P4D are you using?

          Thanks in advance,

          Karl

          p4karl Karl Wirth added a comment - Hi totsubo , I just tried this with a basic Freestyle job and it does fail the build: P4 Task: unshelve review: 999999 ... p4 unshelve -f -s999999 -cdefault + P4JAVA: Change 999999 unknown. P4 Task: attempt: 1 Build step 'Perforce: Unshelve' marked build as failure Finished: FAILURE Therefore please can you provide more context: What type of job is this (FreeStyle, Pipeline, MultiBranch) Please provide the Jenkinsfile, Groovy code or a screenshot of the step (if Freestlye) that you run that uses unshelve. What version of P4D are you using? Thanks in advance, Karl

          Hi Karl and thanks for looking into this.

          I’m new to Jenkins but will try and answer your questions. I’m using the GUI to create the job. No Groovy. I guess that’s called freestyle?

          I think in your example the changelist does not exists.

          My case is where the changelist exists but it has no shelved files. To replicate, I create a changelist with P4V and shelve the files. Then I delete all the shelved files.

          totsubo Jean-Christian Imbeault added a comment - Hi Karl and thanks for looking into this. I’m new to Jenkins but will try and answer your questions. I’m using the GUI to create the job. No Groovy. I guess that’s called freestyle? I think in your example the changelist does not exists. My case is where the changelist exists but it has no shelved files. To replicate, I create a changelist with P4V and shelve the files. Then I delete all the shelved files.
          p4karl Karl Wirth added a comment -

          Hi totsubo, Yes sorry. My test was wrong (I obviously need more coffee ).

          I was able to reproduce this so will pass it onto the developers.

          Reproductions steps:
          (1) Create an empty pending changelist:

          p4 --field Description="Testing" change -o | p4 change -i
          

          (2) Create a freestyle job.

          (3) Add a step that unshelves the changelist you just created. For example:

          (4) Run the job. The step reports there are no files to unshelve and passes:

          P4 Task: unshelve review: 416
          ... p4 unshelve -f -s416 -cdefault -
          p4 unshelve -f -s416 -cdefault
          
          Change 416 - no file(s) to unshelve.
          
          ... duration: (1ms)
          Finished: SUCCESS
          

          This is because the Perforce server treats this as a successful operation (an error didn't actually occur):

          $ p4 unshelve -s 416
          Change 416 - no file(s) to unshelve.
          $ echo $?
          0
          

          Note: For states when the Perforce server returns a non zero error code it does seem to fail the job.

          p4karl Karl Wirth added a comment - Hi totsubo , Yes sorry. My test was wrong (I obviously need more coffee ). I was able to reproduce this so will pass it onto the developers. Reproductions steps: (1) Create an empty pending changelist: p4 --field Description= "Testing" change -o | p4 change -i (2) Create a freestyle job. (3) Add a step that unshelves the changelist you just created. For example: (4) Run the job. The step reports there are no files to unshelve and passes: P4 Task: unshelve review: 416 ... p4 unshelve -f -s416 -cdefault - p4 unshelve -f -s416 -cdefault Change 416 - no file(s) to unshelve. ... duration: (1ms) Finished: SUCCESS This is because the Perforce server treats this as a successful operation (an error didn't actually occur): $ p4 unshelve -s 416 Change 416 - no file(s) to unshelve. $ echo $? 0 Note: For states when the Perforce server returns a non zero error code it does seem to fail the job.

          People

            Unassigned Unassigned
            totsubo Jean-Christian Imbeault
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: