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

P4 plugin : P4_CHANGELIST not available in workflow (pipeline)

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • None
    • jenkins 2.7.2 LTS
      p4-plgin 1.3.8
      jdk 1.8 (sun)
      OS : redhat 7.2

      I'm using p4 plugin for several months in freestyle jobs, and I'm moving to 'pipelines' implementation (workflow if you like)

      According to this documentation, there are some known limitations :
      https://github.com/jenkinsci/p4-plugin/blob/master/SETUP.md

      especially :

      No access to Environment ${VAR} variables

      On the other hand, one line below is written :

      Exposed Variables :

      • P4_CHANGELIST - current changelist (valid for this to be blank when there are no changes).

      Within my pipelines, what I see is that 'P4_CHANGELIST' is not available after a call to p4sync.

      Is it expected ?

      If so, how do I retrieve the changelist at which the sync is done ? (in order to propagate it to further steps and stages in the pipeline)

          [JENKINS-37584] P4 plugin : P4_CHANGELIST not available in workflow (pipeline)

          squalou jenkins created issue -
          p v made changes -
          Flagged New: Impediment [ 10003 ]

          Additionally : setting the 'change' variable in a pipeline seem to have no effect either.
          I've tried to set the 'pin' value to a changelist, and apparently it works but I'm not sure it's a recommended use.

          So to be more precise on the needs here :

          • in a pipeline
          • have a first sync 'at head', get somehow the changelist at which the effective sync is done
          • then in other stages, have other sync done at this very same changelist

          squalou jenkins added a comment - Additionally : setting the 'change' variable in a pipeline seem to have no effect either. I've tried to set the 'pin' value to a changelist, and apparently it works but I'm not sure it's a recommended use. So to be more precise on the needs here : in a pipeline have a first sync 'at head', get somehow the changelist at which the effective sync is done then in other stages, have other sync done at this very same changelist
          Karl Wirth made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Karl Wirth made changes -
          Assignee New: Karl Wirth [ p4karl ]

          small additional comment : using the change number to set the build name is also something we enjoy. Doing so from inside a pipeline would be great. (easy to do as long as the change number is available in a variable somehow)

          squalou jenkins added a comment - small additional comment : using the change number to set the build name is also something we enjoy. Doing so from inside a pipeline would be great. (easy to do as long as the change number is available in a variable somehow)

          Morne Joubert added a comment -

          I also need this, without the knowledge of what number was synced i cannot migrate to pipelines.

          Morne Joubert added a comment - I also need this, without the knowledge of what number was synced i cannot migrate to pipelines.

          Pete McNab added a comment -

          My pipeline has lots of syncs that happen, and I'd also like to see this kind of behavior. Taken a step further though, I'd like to be able to access detected changelists on a per-sync basis.

          If I use the polling option of the checkout method, I'd want to be able to access the list of detected changelists.

          Preferably, I'd either be able to specify the target environment variable for each poll, or have it named based on the client name doing the polling.

          To give more details of my use case, a typical pipeline script would compile multiple targets on multiple platforms. Each target/platform combination can have different sources. I want to be able to skip target/platform combinations if there are no changes to that specific view.

          Pete McNab added a comment - My pipeline has lots of syncs that happen, and I'd also like to see this kind of behavior. Taken a step further though, I'd like to be able to access detected changelists on a per-sync basis. If I use the polling option of the checkout method, I'd want to be able to access the list of detected changelists. Preferably, I'd either be able to specify the target environment variable for each poll, or have it named based on the client name doing the polling. To give more details of my use case, a typical pipeline script would compile multiple targets on multiple platforms. Each target/platform combination can have different sources. I want to be able to skip target/platform combinations if there are no changes to that specific view .

          Pete McNab added a comment -

          I'd add another note that in my opinion in the case where a job does multiple syncs/polls, P4_CHANGELIST should contain a deduplicated list of all the changes detected.

          Pete McNab added a comment - I'd add another note that in my opinion in the case where a job does multiple syncs/polls, P4_CHANGELIST should contain a deduplicated list of all the changes detected.
          Paul Allen made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

            p4karl Karl Wirth
            squalou squalou jenkins
            Votes:
            7 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: