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

Add option "Use Upstream Project revision" similar to that on the legacy perforce plugin

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • p4-plugin

      Please could you consider adding a "Use Upstream Project revision" checkbox to the p4-plugin similar to that available in the legacy "perforce-plugin".

      It is a useful feature when jobs are setup to run after an upstream job with artifacts being copied. In many circumstances like this it is important that the downstream job uses the same file revisions as the upstream job that created the artifacts.

      I think it may be already possible to do this with "Parameterized Trigger Plugin" in the upstream job setting "change" parameter on the downstream job, but then all the downstream jobs have to be listed in the upstream job which is more complex to configure.

          [JENKINS-33163] Add option "Use Upstream Project revision" similar to that on the legacy perforce plugin

          Jim Poje added a comment -

          We are facing the issue with the p4 software plugin in the case where we have parent/child jobs running. When we triggered the parent's job it captures the P4_CHANGELIST to pass down to the child job. However, in between running the parent job and the child job, if there are changelists submitted to perforce, then the value for P4_CHANGELIST is changed for the child job. This is not good for us since we need to make sure that both the parent and child jobs are syncing down to the same P4_CHANGELIST. Is there anyway that the p4 plugin will allow us to set the P4_CHANGELIST and not use the latest changelist in order for us to ensure that the same P4_CHANGELIST are used by both parent and child jobs?

          The "Use the upstream project revision" appears to be a solution to resolve, and ask this be prioritized.

          Jim Poje added a comment - We are facing the issue with the p4 software plugin in the case where we have parent/child jobs running. When we triggered the parent's job it captures the P4_CHANGELIST to pass down to the child job. However, in between running the parent job and the child job, if there are changelists submitted to perforce, then the value for P4_CHANGELIST is changed for the child job. This is not good for us since we need to make sure that both the parent and child jobs are syncing down to the same P4_CHANGELIST. Is there anyway that the p4 plugin will allow us to set the P4_CHANGELIST and not use the latest changelist in order for us to ensure that the same P4_CHANGELIST are used by both parent and child jobs? The "Use the upstream project revision" appears to be a solution to resolve, and ask this be prioritized.

          Karl Wirth added a comment -

          One workaround is to use parameterized jobs and the following plugin:

          https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin

          Create a downstream job with a string parameter 'P4CL' then pin the downstream job at the Perforce label '${P4CL}'. When the upstream job calls the downstream job set 'P4CL= ${P4_CHANGELIST)'.

          In this was the downstream jobs runs with the same changelist number that was used by the upstream job. In testing this also sets 'P4_CHANGELIST' to '${P4CL}'

          Karl Wirth added a comment - One workaround is to use parameterized jobs and the following plugin: https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin Create a downstream job with a string parameter 'P4CL' then pin the downstream job at the Perforce label '${P4CL}'. When the upstream job calls the downstream job set 'P4CL= ${P4_CHANGELIST)'. In this was the downstream jobs runs with the same changelist number that was used by the upstream job. In testing this also sets 'P4_CHANGELIST' to '${P4CL}'

          Code changed in jenkins
          User: Paul Allen
          Path:
          SETUP.md
          http://jenkins-ci.org/commit/p4-plugin/0a667176ad6dfb38ac755cc8e556875562dcd9ce
          Log:
          Document downstream changelists.

          Workaround for JENKINS-33163.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Paul Allen Path: SETUP.md http://jenkins-ci.org/commit/p4-plugin/0a667176ad6dfb38ac755cc8e556875562dcd9ce Log: Document downstream changelists. Workaround for JENKINS-33163 .

          Yes, we are already using that workaround using the pinned downstream build.
          However, as I said in the description of the issue that this is not good as you then have to list all downsteam jobs in parameterized trigger section of the upstream job, rather than in the downstream job (which is the usual method to link jobs in jenkins)

          Andrew Barnish added a comment - Yes, we are already using that workaround using the pinned downstream build. However, as I said in the description of the issue that this is not good as you then have to list all downsteam jobs in parameterized trigger section of the upstream job, rather than in the downstream job (which is the usual method to link jobs in jenkins)

          Paul Allen added a comment -

          1.4.9 (documentation)

          Paul Allen added a comment - 1.4.9 (documentation)

          Paul Allen added a comment -

          Fixed in 1.4.9

          Paul Allen added a comment - Fixed in 1.4.9

          Philip Aston added a comment -

          I'm seeing behaviour similar to that reported by Jim Poje above.

          I'm following the documented pattern, but the change list reported by $P4_CHANGELIST (when captured by the parent job and passed to as a parameter to trigger the child job) reflects more recent commits.

          I suspect there may have been a regression in the plugin. I'm going to downgrade (1.10.10 -> 1.9.6) and monitor over the next few days.

          Philip Aston added a comment - I'm seeing behaviour similar to that reported by Jim Poje above. I'm following the documented pattern, but the change list reported by $P4_CHANGELIST (when captured by the parent job and passed to as a parameter to trigger the child job) reflects more recent commits. I suspect there may have been a regression in the plugin. I'm going to downgrade (1.10.10 -> 1.9.6) and monitor over the next few days.

          Karl Wirth added a comment -

          Hi philipa - Has this ever worked for you? From this thread, it looks like we didnt put in a code fix and only provided a workaround where you avoided using P4_CHANGELIST.

          Karl Wirth added a comment - Hi philipa - Has this ever worked for you? From this thread, it looks like we didnt put in a code fix and only provided a workaround where you avoided using P4_CHANGELIST.

          Philip Aston added a comment - - edited

          I've only noticed it since upgrading 1.9.6 -> 1.10.10 recently. But yes, I could have missed it before. I'll pay close attention over the next few days and let you know.

          Which workaround are you referring to? The one you mentioned in comment-273024 was documented under this issue and is what I'm using.

           

          Philip Aston added a comment - - edited I've only noticed it since upgrading 1.9.6 -> 1.10.10 recently. But yes, I could have missed it before. I'll pay close attention over the next few days and let you know. Which workaround are you referring to? The one you mentioned in comment-273024 was documented under this issue and is what I'm using.  

          Karl Wirth added a comment -

          Hi philipa - Yes that's the one. I'll do some basic tests here to see if I can repro this.

          Karl Wirth added a comment - Hi philipa - Yes that's the one. I'll do some basic tests here to see if I can repro this.

          Karl Wirth added a comment -

          Hi philipa - I just tried the following test with 1.10.10 and it seemed to work:

          (1) Add CL 123 to downstream job directory.

          (2) Add CL 124 to upstream job directory.

          (3) Trigger upstream job that has a 20 second sleep as a build step.

          (4) Add 2 more CLs to each directory.

          (5) Downstream job is triggered with CL124 as the paramater and jobs is pinned to that CL. P4-Plugin looks for most recent CL in downstream depot path and syncs CL 123.

           

          My setup is - Upstream job...

           

          Downstream job...

          and:

          Karl Wirth added a comment - Hi philipa - I just tried the following test with 1.10.10 and it seemed to work: (1) Add CL 123 to downstream job directory. (2) Add CL 124 to upstream job directory. (3) Trigger upstream job that has a 20 second sleep as a build step. (4) Add 2 more CLs to each directory. (5) Downstream job is triggered with CL124 as the paramater and jobs is pinned to that CL. P4-Plugin looks for most recent CL in downstream depot path and syncs CL 123.   My setup is - Upstream job...   Downstream job... and:

          Philip Aston added a comment -

          Thanks for investigating Karl. Yes, that configuration corresponds to mine. I guess the one difference might be that my jobs run on nodes on different machines, with different workspaces. Also, the later commit will trigger another run of the upstream job (on a different machine).

          Its not recurred since I've downgraded, so I'm going to run with this for 1.9.6 for next week, then I'll try upgrading again.

          Philip Aston added a comment - Thanks for investigating Karl. Yes, that configuration corresponds to mine. I guess the one difference might be that my jobs run on nodes on different machines, with different workspaces. Also, the later commit will trigger another run of the upstream job (on a different machine). Its not recurred since I've downgraded, so I'm going to run with this for 1.9.6 for next week, then I'll try upgrading again.

          Karl Wirth added a comment -

          Hi philipa - Thanks and happy I can help.

          Karl Wirth added a comment - Hi philipa - Thanks and happy I can help.

          Philip Aston added a comment -

          I ran for a week 1.9.6 with no issues.

          I switched back to 1.10.10, and saw the problem again. It's a production config, so I've reverted back to 1.9.6.

          Philip Aston added a comment - I ran for a week 1.9.6 with no issues. I switched back to 1.10.10, and saw the problem again. It's a production config, so I've reverted back to 1.9.6.

          Karl Wirth added a comment -

          Hi philipa - Thanks. I'll test on WIndows and Linux build slaves and get back to you.

          Karl Wirth added a comment - Hi philipa - Thanks. I'll test on WIndows and Linux build slaves and get back to you.

          Karl Wirth added a comment -

          Hi philipa

          Finally got a chance to test this properly and still no luck in reproducing it. Can you please send an email to 'support@perforce.com' for my attention and send the full console logs for the two jobs when th. I'll try and figure out what I'm missing.

          Thanks in advance,

          Karl

          Karl Wirth added a comment - Hi philipa Finally got a chance to test this properly and still no luck in reproducing it. Can you please send an email to 'support@perforce.com' for my attention and send the full console logs for the two jobs when th. I'll try and figure out what I'm missing. Thanks in advance, Karl

          Philip Aston added a comment -

          Thanks p4karl. I've upgraded the plugin again; I'll send you the logs when I see the next failure.

          Philip Aston added a comment - Thanks p4karl . I've upgraded the plugin again; I'll send you the logs when I see the next failure.

          Karl Wirth added a comment -

          Hi philipa - Thanks.

          Karl Wirth added a comment - Hi philipa - Thanks.

            p4paul Paul Allen
            barnish Andrew Barnish
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: