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

Trigger job by creation of new p4 labels

    Details

    • Similar Issues:

      Description

      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?

        Attachments

          Activity

          Hide
          p4karl 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'})
          
          Show
          p4karl 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' })
          Hide
          p4karl Karl Wirth added a comment -

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

          Show
          p4karl Karl Wirth added a comment - Hi Matthew Dews - Were you able to test this. Did it work?
          Hide
          matthew_dews Matthew Dews added a comment -

          Hi Karl Wirth, 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.

          Show
          matthew_dews Matthew Dews added a comment - Hi Karl Wirth , 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.
          Hide
          p4karl 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.

          Show
          p4karl 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.

            People

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

              Dates

              • Created:
                Updated: