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

      I'd like to accomplish the following:

      • Create a new label in Helix
      • Jenkins job picks up that a new label was created and does a build at that label/changelist
      • Other submissions do not trigger the job to run

      As far as I can tell there's no way to accomplish this with the current features of P4 Jenkins. Is that correct or is there something I'm missing?

          [JENKINS-57458] Trigger job by creation of new p4 labels

          Karl Wirth added a comment -

          Hi matthew_dews. You could possibly do this with a paramaterized job and Perforce command triggers.

          (1) Create  a Jenkins job that takes label as a parameter and builds at that label.

          (2) Create a post command trigger on 'tag' and 'label' that fires starts the job passing the label as the paramater.

          Note: The difficult part of this solution is deciding what paths to build. If your the label contains the exact paths to build you could use that to build up the workspace.

          More on Perforce command triggers can be found here:

             https://www.perforce.com/manuals/p4sag/Content/P4SAG/scripting.triggers.order.html

          And below is a really simple script I have used in the past to fire a Jenkins job:

          $ cat /scripts/fire_jenkins_job.py 
          import jenkins
          import sys
          url = 'JenkinsServer:8080'
          job = 'Freestyle_Paramaterized'
          j = jenkins.Jenkins(url)
          j.build_job(job, parameters={'LABEL':'label1'})
          

          Karl Wirth added a comment - Hi matthew_dews . You could possibly do this with a paramaterized job and Perforce command triggers. (1) Create  a Jenkins job that takes label as a parameter and builds at that label. (2) Create a post command trigger on 'tag' and 'label' that fires starts the job passing the label as the paramater. Note : The difficult part of this solution is deciding what paths to build. If your the label contains the exact paths to build you could use that to build up the workspace. More on Perforce command triggers can be found here:    https://www.perforce.com/manuals/p4sag/Content/P4SAG/scripting.triggers.order.html And below is a really simple script I have used in the past to fire a Jenkins job: $ cat /scripts/fire_jenkins_job.py import jenkins import sys url = 'JenkinsServer:8080' job = 'Freestyle_Paramaterized' j = jenkins.Jenkins(url) j.build_job(job, parameters={ 'LABEL' : 'label1' })

          Karl Wirth added a comment -

          Hi matthew_dews - Were you able to test this. Did it work?

          Karl Wirth added a comment - Hi matthew_dews - Were you able to test this. Did it work?

          Matthew Dews added a comment -

          Hi p4karl, I have not had a chance to try this out yet and based on current priorities don't have plans to. This feature request came out of someone migrating their build process to Jenkins and asking if a "label, then build" workflow was possible. I think a "build, then label" workflow which p4 Jenkins already supports is a better fit for us since it is less maintence for our Helix/Perforce admins.

          Matthew Dews added a comment - Hi p4karl , I have not had a chance to try this out yet and based on current priorities don't have plans to. This feature request came out of someone migrating their build process to Jenkins and asking if a "label, then build" workflow was possible. I think a "build, then label" workflow which p4 Jenkins already supports is a better fit for us since it is less maintence for our Helix/Perforce admins.

          Karl Wirth added a comment -

          Hi matthew_dews, Thanks for the feedback. I agree that build then label is the use case we regularly see. I will pass this onto the devs to record the request.

          Karl Wirth added a comment - Hi matthew_dews , Thanks for the feedback. I agree that build then label is the use case we regularly see. I will pass this onto the devs to record the request.

            Unassigned Unassigned
            matthew_dews Matthew Dews
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: