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

Allow a pipeline script to determine changelist from a perforce path without creating a client

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • p4-plugin
    • None

      Use case:

      I run several parallel branches of my build on different nodes (Windows, Mac, Linux), and need to be able to pin a checkout of the code to a change list. To do this I have a setup stage in my declarative pipeline that uses the P4Groovy object to access this.

      Example:

      // Sigh, p4groovy require a workspace ...
      def p4 = p4(credential: 'Perforce-Credentials',
          workspace: manualSpec(
              name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}-pinned', 
              spec: clientSpec(
                   view: '''//Nomad/${branch}/src/... //${P4_CLIENT}/...''')))
      change = p4.run('changes', '-m1', "//Nomad/${branch}/...")[0]["change"]
      

      This require me to approve of p4.run as a signature as it is considered a dangerous function. Though with the right credentials, and path; there is no need to create a manual client spec, then query it. This can be done straight out using p4 binary:

      p4 changes -m1 //path/...
      

      Please, for some of these simple operations it would be very helpful to expose an interface such that I could obtain e.g. latest change given a path, latest commit username, etc.
       

            Unassigned Unassigned
            enaess Eivind
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: