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

P4_CLIENT environment variable wrong for parallel builds

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • p4-plugin
    • None
    • Jenkins v2.235.1
      P4 Plugin 1.10.13
      Master and Server on Debian
      Agent on Windows 10
      JAva 8

      I recently upgraded from version 1.9.5, where I didn't see this issue.  I have several FreeStyleBuilds that run on Swarm reviews.  They execute concurrent builds, one per agent.  They use the P4_CLIENT environment variable to find what files are unshelved in the default changelist, but when two builds start at similar times one of them will have the P4_CLIENT variable from the other.

      My client names do not use the executor number because there is only ever one executor, so this is not a duplicate of JENKINS-60213.

      I have managed to reproduce the error with the attached build configuration (server credential name removed).  It has a timer trigger for 1/minute but I had to spam the Build button with two agents connected to the master to get the job to fail.

        1. console3_SUCCESS.txt
          3 kB
        2. console4_FAILURE.txt
          3 kB
        3. console5_SUCCESS.txt
          3 kB
        4. config.xml
          3 kB

          [JENKINS-63447] P4_CLIENT environment variable wrong for parallel builds

          Nick Ridgway created issue -

          Karl Wirth added a comment -

          Hi rebnridgway,

          Thanks for the details. Can you get me the console log from the failed job and the working one either side (for example job 45 46 and 47).

          As a first step I tried this one Linux and couldn't repro so will source a couple of extra Windows machines and will try on those.

          My Linux code was:

           

          sleep 60  # Tried with and without the sleep.
          echo jenkins-NODE_NAME-JOB_NAME: jenkins-$NODE_NAME-$JOB_NAME
          echo P4CLIENT: $P4CLIENTif [ "jenkins-$NODE_NAME-$JOB_NAME" = "$P4CLIENT" ]; then
              echo "Strings are equal."
              exit 0
          else
              echo "Strings are not equal."
              exit 1
          fi
          

           

          Karl Wirth added a comment - Hi rebnridgway , Thanks for the details. Can you get me the console log from the failed job and the working one either side (for example job 45 46 and 47). As a first step I tried this one Linux and couldn't repro so will source a couple of extra Windows machines and will try on those. My Linux code was:   sleep 60 # Tried with and without the sleep. echo jenkins-NODE_NAME-JOB_NAME: jenkins-$NODE_NAME-$JOB_NAME echo P4CLIENT: $P4CLIENTif [ "jenkins-$NODE_NAME-$JOB_NAME" = "$P4CLIENT" ]; then echo "Strings are equal." exit 0 else echo "Strings are not equal." exit 1 fi  

          Nick Ridgway added a comment -

          I have attached console logs (minus some server details) showing the failure.

          What's the difference between P4CLIENT and P4_CLIENT?  I am using the latter in my job but you used the former in your test.

          Nick Ridgway added a comment - I have attached console logs (minus some server details) showing the failure. What's the difference between P4CLIENT and P4_CLIENT?  I am using the latter in my job but you used the former in your test.
          Nick Ridgway made changes -
          Attachment New: console3_SUCCESS.txt [ 52409 ]
          Attachment New: console4_FAILURE.txt [ 52410 ]
          Attachment New: console5_SUCCESS.txt [ 52411 ]

          Karl Wirth added a comment -

          Hi rebnridgway - Good spot thanks.

          Its an environment variable I set that should be the same as P4_CLIENT but its better that I test the real variable!

          First couple of Linux passes since fixing the script still not showing it but I'll keep testing then move onto Windows.

          Karl Wirth added a comment - Hi rebnridgway - Good spot thanks. Its an environment variable I set that should be the same as P4_CLIENT but its better that I test the real variable! First couple of Linux passes since fixing the script still not showing it but I'll keep testing then move onto Windows.
          Karl Wirth made changes -
          Link New: This issue relates to JENKINS-64879 [ JENKINS-64879 ]

            Unassigned Unassigned
            rebnridgway Nick Ridgway
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: