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

p4 Plugin does not trigger Pipeline builds

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: p4-plugin
    • Labels:
    • Environment:
      Jenkins 1.651.2
      p4 Plugin 1.4.0
      Pipeline 2.1
      Pipeline SCM 2.0
    • Similar Issues:

      Description

      I didn't want this to get lost since JENKINS-29979 was closed out.

      The P4 Trigger isn't firing a Pipeline job off when a POST request comes in per the /p4/ help page in Jenkins, or if you do a manual trigger. I do see the request come in, after which P4 probes the Pipeline projects, but then nothing happens:

      Jun 02, 2016 11:36:16 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange
      Received trigger event: {change:123456,p4port: "p4host.example.org:1666"}
      Jun 02, 2016 11:36:16 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
      P4: probing: pipeline-project-01
      Jun 02, 2016 11:36:16 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
      P4: probing: pipeline-project-02
      Jun 02, 2016 11:36:16 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
      P4: probing: pipeline-project-03
      

      For now, we are doing a poll every couple of hours, but it would be great to use the Trigger mechanism in the future.

        Attachments

          Activity

          Hide
          jenkinsim Kevin Sim added a comment - - edited

          HI all,

          I observed the same behaviour in snapshot 1.4.1.
          I noticed in P4Trigger.java, matchServer() always return false, even when I have set the pipeline to sync from a Perforce Password Credential.

          Basically item.getSCMs().size() is always 0.

          private boolean matchServer(Job<?, ?> job, String port) {
          		//Get all the trigger for this Job
          		SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);
          
          		if(item != null) {
          //As soon as we find a match, return
          			for (SCM scmTrigger : item.getSCMs()) {
          

          Any tips to fix this would be greatly appreciated!

          Thanks,
          Kev

          Show
          jenkinsim Kevin Sim added a comment - - edited HI all, I observed the same behaviour in snapshot 1.4.1. I noticed in P4Trigger.java, matchServer() always return false, even when I have set the pipeline to sync from a Perforce Password Credential. Basically item.getSCMs().size() is always 0. private boolean matchServer(Job<?, ?> job, String port) { //Get all the trigger for this Job SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job); if (item != null ) { //As soon as we find a match, return for (SCM scmTrigger : item.getSCMs()) { Any tips to fix this would be greatly appreciated! Thanks, Kev
          Hide
          kmott Kyle Mott added a comment - - edited

          I have confirmed that build 1.4.1 of the p4 plugin seems to generally fix the problem described in this ticket. However, I have noticed one peculiar side-effect of the change. Builds are triggered when a change notification comes in, but there doesn't seem to be any scoping to figure out which builds should be triggered. For example, if I have Pipeline projects configured like this:

          NAME: project1-tip
          P4PORT: p4.example.org:1666
          DEPOT: //depot/project1/tip
          
          NAME: project2-tip
          P4PORT: p4.example.org:1666
          DEPOT: //depot/project1/tip/src/project2/tip
          
          NAME: project3-tip
          P4PORT: p4.example.org:1666
          DEPOT: //depot/project1/tip/src/project3/tip
          

          When the notifications for changes on project1-tip are received by Jenkins, Jenkins triggers builds on all 3 projects, even though the changelist ID for the notification includes files ONLY in project 1 that were changed. For example, here's a couple change notifications that seem to trigger builds on project 2 and 3 that I would not expect to happen:

          CHANGEID: 879911
          FILES: //depot/project1/tip/myfile.cpp
          P4PORT: p4.example.org:1666
          
          CHANGEID: 880021
          FILES: //depot/project1/tip/src/myclass.cpp, //depot/project1/tip/src/otherclass.cpp, //depot/project1/tip/Jenkinsfile
          P4PORT: p4.example.org:1666
          
          Show
          kmott Kyle Mott added a comment - - edited I have confirmed that build 1.4.1 of the p4 plugin seems to generally fix the problem described in this ticket. However, I have noticed one peculiar side-effect of the change. Builds are triggered when a change notification comes in, but there doesn't seem to be any scoping to figure out which builds should be triggered. For example, if I have Pipeline projects configured like this: NAME: project1-tip P4PORT: p4.example.org:1666 DEPOT: //depot/project1/tip NAME: project2-tip P4PORT: p4.example.org:1666 DEPOT: //depot/project1/tip/src/project2/tip NAME: project3-tip P4PORT: p4.example.org:1666 DEPOT: //depot/project1/tip/src/project3/tip When the notifications for changes on project1-tip are received by Jenkins, Jenkins triggers builds on all 3 projects, even though the changelist ID for the notification includes files ONLY in project 1 that were changed. For example, here's a couple change notifications that seem to trigger builds on project 2 and 3 that I would not expect to happen: CHANGEID: 879911 FILES: //depot/project1/tip/myfile.cpp P4PORT: p4.example.org:1666 CHANGEID: 880021 FILES: //depot/project1/tip/src/myclass.cpp, //depot/project1/tip/src/otherclass.cpp, //depot/project1/tip/Jenkinsfile P4PORT: p4.example.org:1666
          Hide
          jenkinsim Kevin Sim added a comment -

          Hi Kyle Mott, Paul Allen,

          May I ask if Pipeline plugin 2.x versions are compatible with this new trigger feature in p4-plugin?

          I couldn't get it running on my setup
          1. Pipeline 2.x
          2. p4-plugin 1.4.1

          But if it working if I were to use 1.6 pipeline as specified in https://github.com/jenkinsci/p4-plugin/blob/master/pom.xml
          1. Pipeline 1.6
          2. p4-plugin 1.4.1

          Thanks

          Show
          jenkinsim Kevin Sim added a comment - Hi Kyle Mott , Paul Allen , May I ask if Pipeline plugin 2.x versions are compatible with this new trigger feature in p4-plugin? I couldn't get it running on my setup 1. Pipeline 2.x 2. p4-plugin 1.4.1 But if it working if I were to use 1.6 pipeline as specified in https://github.com/jenkinsci/p4-plugin/blob/master/pom.xml 1. Pipeline 1.6 2. p4-plugin 1.4.1 Thanks
          Hide
          p4paul Paul Allen added a comment -

          Just tested the following configuration...
          1. Pipeline 2.x (Jenkins 2.8)
          2. p4-plugin 1.4.2

          It seems OK; however if you have pinned the change the trigger seems to not calculate the range.

          Show
          p4paul Paul Allen added a comment - Just tested the following configuration... 1. Pipeline 2.x (Jenkins 2.8) 2. p4-plugin 1.4.2 It seems OK; however if you have pinned the change the trigger seems to not calculate the range.
          Hide
          jenkinsim Kevin Sim added a comment -

          Paul Allen Thanks for checking!
          Finally I can get your trigger running on Jenkins 2.8!

          However I still have issues getting this running in other Jenkins instances of mine.
          I'm suspecting it only works with the right combination of dependent plugins..Do you have any tips for me to debug this further? Or logs that I can look at to determine the root cause?

          Show
          jenkinsim Kevin Sim added a comment - Paul Allen Thanks for checking! Finally I can get your trigger running on Jenkins 2.8! However I still have issues getting this running in other Jenkins instances of mine. I'm suspecting it only works with the right combination of dependent plugins..Do you have any tips for me to debug this further? Or logs that I can look at to determine the root cause?
          Hide
          p4paul Paul Allen added a comment -

          The log should record "P4: probing:" and "P4: poking:" during the trigger event or perhaps an exception (Manage Jenkins > System Log).

          Show
          p4paul Paul Allen added a comment - The log should record "P4: probing:" and "P4: poking:" during the trigger event or perhaps an exception (Manage Jenkins > System Log).
          Hide
          jenkinsim Kevin Sim added a comment -

          OK.
          Btw, how can the pipeline job get the $change value from trigger?
          My use case would be that the triggered job syncs from $change specified in trigger, and not having to sync from tip.

          Show
          jenkinsim Kevin Sim added a comment - OK. Btw, how can the pipeline job get the $change value from trigger? My use case would be that the triggered job syncs from $change specified in trigger, and not having to sync from tip.
          Hide
          kmott Kyle Mott added a comment -

          Paul Allen, here's what my Jenkins log looks like just after the trigger is received by Jenkins:

          Jun 29, 2016 11:02:57 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange
          Received trigger event: {change:905738,p4port: "p4.example.org:1666"}
          Jun 29, 2016 11:02:57 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
          P4: probing: project1-tip
          Jun 29, 2016 11:02:57 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke
          P4: poking: project1-tip
          Jun 29, 2016 11:03:06 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
          P4: probing: project2-tip
          Jun 29, 2016 11:03:06 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke
          P4: poking: project2-tip
          Jun 29, 2016 11:03:10 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
          P4: probing: project3-tip
          Jun 29, 2016 11:03:10 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke
          P4: poking: project3-tip
          Jun 29, 2016 11:03:25 AM INFO org.jenkinsci.plugins.p4.PerforceScm guessBrowser
          Unable to guess repository browser.
          

          And here's what the full consoleText looks like from a corresponding failed build (almost as if the Jenkinsfile couldn't be found in Perforce, but I know it's there):

          Started by an SCM change
          (p4):cmd:... p4 client -o jenkins-project1-tip
          p4 client -o jenkins-project1-tip
          
          (p4):stop:6
          (p4):cmd:... p4 info
          p4 info
          
          (p4):stop:7
          
          P4 Task: establishing connection.
          ... server: p4.example.org:1666
          ... node: jenkins
          (p4):cmd:... p4 client -o jenkins-project1-tip
          p4 client -o jenkins-project1-tip
          
          (p4):stop:8
          (p4):cmd:... p4 client -i
          p4 client -i
          
          Client jenkins-project1-tip not changed.
          
          (p4):stop:9
          ... client: jenkins-project1-tip
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:6
          (p4):cmd:... p4 info
          p4 info
          
          (p4):stop:7
          
          P4 Task: establishing connection.
          ... server: p4.example.org:1666
          ... node: jenkins
          (p4):cmd:... p4 client -o jenkins-project1-tip
          p4 client -o jenkins-project1-tip
          
          (p4):stop:8
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:9
          (p4):cmd:... p4 client -i
          p4 client -i
          
          Client jenkins-project1-tip.clonescript not changed.
          
          (p4):stop:10
          (p4):cmd:... p4 client -f -s -t jenkins-project1-tip jenkins-project1___
          p4 client -f -s -t jenkins-project1-tip jenkins-project1-tip.clonescript
          
          Client jenkins-project1-tip.clonescript not changed.
          
          (p4):stop:11
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:12
          (p4):cmd:... p4 client -i
          p4 client -i
          
          Client jenkins-project1-tip.clonescript not changed.
          
          (p4):stop:13
          ... client: jenkins-project1-tip.clonescript
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:6
          (p4):cmd:... p4 info
          p4 info
          
          (p4):stop:7
          (p4):cmd:... p4 counter change
          p4 counter change
          
          (p4):stop:8
          (p4):cmd:... p4 changes -m1 -ssubmitted //jenkins-project1-tip.clonescript/...
          p4 changes -m1 -ssubmitted //jenkins-project1-tip.clonescript/...
          
          Change 905738 on 2016/06/29 by user@clientspec 'Change description'
          (p4):stop:9
          Building on Node: master
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:6
          (p4):cmd:... p4 info
          p4 info
          
          (p4):stop:7
          
          P4 Task: establishing connection.
          ... server: p4.example.org:1666
          ... node: jenkins
          
          P4 Task: reverting all pending and shelved revisions.
          (p4):cmd:... p4 revert /home/jenkins/jobs/project1-tip/workspace%40script/...
          p4 revert /home/jenkins/jobs/project1-tip/workspace%40script/...
          
          /home/jenkins/jobs/project1-tip/workspace%40script/... - file(s) not opened on this client.
          
          (p4):stop:8
          ... rm [abandoned files]
          duration: (107ms)
          
          P4 Task: cleaning workspace to match have list.
          (p4):cmd:... p4 reconcile -w -f /home/jenkins/jobs/project1-tip/workspace%40script___
          p4 reconcile -w -f /home/jenkins/jobs/project1-tip/workspace%40script/...
          
          (p4):stop:9
          duration: 2m 44s
          
          P4 Task: syncing files at change: 833613
          (p4):cmd:... p4 sync -q /home/jenkins/jobs/project1-tip/workspace%40script/...@833___
          p4 sync -q /home/jenkins/jobs/project1-tip/workspace%40script/...@833613
          
          (p4):stop:10
          (p4):cmd:... p4 client -i
          p4 client -i
          
          Client jenkins-project1-tip.clonescript not changed.
          
          (p4):stop:11
          duration: (367ms)
          
          P4 Task: saving built changes.
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:6
          (p4):cmd:... p4 info
          p4 info
          
          (p4):stop:7
          (p4):cmd:... p4 changes -m100 //jenkins-project1-tip.clonescript/...@905705,833613
          p4 changes -m100 //jenkins-project1-tip.clonescript/...@905705,833613
          
          (p4):stop:8
          (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript
          p4 client -o jenkins-project1-tip.clonescript
          
          (p4):stop:6
          (p4):cmd:... p4 info
          p4 info
          
          (p4):stop:7
          ... done
          
          ERROR: /home/jenkins/jobs/project1-tip/workspace@script/Jenkinsfile not found
          Finished: FAILURE
          

          It's almost as if the changelist calculations don't include the Jenkinsfile for some reason. Why would that be?

          Show
          kmott Kyle Mott added a comment - Paul Allen , here's what my Jenkins log looks like just after the trigger is received by Jenkins: Jun 29, 2016 11:02:57 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange Received trigger event: {change:905738,p4port: "p4.example.org:1666"} Jun 29, 2016 11:02:57 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs P4: probing: project1-tip Jun 29, 2016 11:02:57 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke P4: poking: project1-tip Jun 29, 2016 11:03:06 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs P4: probing: project2-tip Jun 29, 2016 11:03:06 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke P4: poking: project2-tip Jun 29, 2016 11:03:10 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs P4: probing: project3-tip Jun 29, 2016 11:03:10 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke P4: poking: project3-tip Jun 29, 2016 11:03:25 AM INFO org.jenkinsci.plugins.p4.PerforceScm guessBrowser Unable to guess repository browser. And here's what the full consoleText looks like from a corresponding failed build (almost as if the Jenkinsfile couldn't be found in Perforce, but I know it's there): Started by an SCM change (p4):cmd:... p4 client -o jenkins-project1-tip p4 client -o jenkins-project1-tip (p4):stop:6 (p4):cmd:... p4 info p4 info (p4):stop:7 P4 Task: establishing connection. ... server: p4.example.org:1666 ... node: jenkins (p4):cmd:... p4 client -o jenkins-project1-tip p4 client -o jenkins-project1-tip (p4):stop:8 (p4):cmd:... p4 client -i p4 client -i Client jenkins-project1-tip not changed. (p4):stop:9 ... client: jenkins-project1-tip (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:6 (p4):cmd:... p4 info p4 info (p4):stop:7 P4 Task: establishing connection. ... server: p4.example.org:1666 ... node: jenkins (p4):cmd:... p4 client -o jenkins-project1-tip p4 client -o jenkins-project1-tip (p4):stop:8 (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:9 (p4):cmd:... p4 client -i p4 client -i Client jenkins-project1-tip.clonescript not changed. (p4):stop:10 (p4):cmd:... p4 client -f -s -t jenkins-project1-tip jenkins-project1___ p4 client -f -s -t jenkins-project1-tip jenkins-project1-tip.clonescript Client jenkins-project1-tip.clonescript not changed. (p4):stop:11 (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:12 (p4):cmd:... p4 client -i p4 client -i Client jenkins-project1-tip.clonescript not changed. (p4):stop:13 ... client: jenkins-project1-tip.clonescript (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:6 (p4):cmd:... p4 info p4 info (p4):stop:7 (p4):cmd:... p4 counter change p4 counter change (p4):stop:8 (p4):cmd:... p4 changes -m1 -ssubmitted //jenkins-project1-tip.clonescript/... p4 changes -m1 -ssubmitted //jenkins-project1-tip.clonescript/... Change 905738 on 2016/06/29 by user@clientspec 'Change description' (p4):stop:9 Building on Node: master (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:6 (p4):cmd:... p4 info p4 info (p4):stop:7 P4 Task: establishing connection. ... server: p4.example.org:1666 ... node: jenkins P4 Task: reverting all pending and shelved revisions. (p4):cmd:... p4 revert /home/jenkins/jobs/project1-tip/workspace%40script/... p4 revert /home/jenkins/jobs/project1-tip/workspace%40script/... /home/jenkins/jobs/project1-tip/workspace%40script/... - file(s) not opened on this client. (p4):stop:8 ... rm [abandoned files] duration: (107ms) P4 Task: cleaning workspace to match have list. (p4):cmd:... p4 reconcile -w -f /home/jenkins/jobs/project1-tip/workspace%40script___ p4 reconcile -w -f /home/jenkins/jobs/project1-tip/workspace%40script/... (p4):stop:9 duration: 2m 44s P4 Task: syncing files at change: 833613 (p4):cmd:... p4 sync -q /home/jenkins/jobs/project1-tip/workspace%40script/...@833___ p4 sync -q /home/jenkins/jobs/project1-tip/workspace%40script/...@833613 (p4):stop:10 (p4):cmd:... p4 client -i p4 client -i Client jenkins-project1-tip.clonescript not changed. (p4):stop:11 duration: (367ms) P4 Task: saving built changes. (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:6 (p4):cmd:... p4 info p4 info (p4):stop:7 (p4):cmd:... p4 changes -m100 //jenkins-project1-tip.clonescript/...@905705,833613 p4 changes -m100 //jenkins-project1-tip.clonescript/...@905705,833613 (p4):stop:8 (p4):cmd:... p4 client -o jenkins-project1-tip.clonescript p4 client -o jenkins-project1-tip.clonescript (p4):stop:6 (p4):cmd:... p4 info p4 info (p4):stop:7 ... done ERROR: /home/jenkins/jobs/project1-tip/workspace@script/Jenkinsfile not found Finished: FAILURE It's almost as if the changelist calculations don't include the Jenkinsfile for some reason. Why would that be?
          Hide
          p4paul Paul Allen added a comment -

          Please can you check if the JenkinsFiles is in the Workspace directory:
          /home/jenkins/jobs/project1-tip/workspace@script/Jenkinsfile

          In addition, please can you uncheck the 'QUIET Perforce messages' option, this will remove the '-q' flag from the sync and allow us to see what was sync'ed. Alternatively try the 'Force clean and sync' option.

          Show
          p4paul Paul Allen added a comment - Please can you check if the JenkinsFiles is in the Workspace directory: /home/jenkins/jobs/project1-tip/workspace@script/Jenkinsfile In addition, please can you uncheck the 'QUIET Perforce messages' option, this will remove the '-q' flag from the sync and allow us to see what was sync'ed. Alternatively try the 'Force clean and sync' option.
          Hide
          kmott Kyle Mott added a comment -

          The Jenkinsfile is in there now (as of builds 155 and newer), which are now succeeding.

          FWIW, here's my p4sync line in my Jenkinsfile. I just changed 'quiet:false', and will see if builds fail the same way as they were yesterday, unable to find the Jenkinsfile. If they do, I will post the logs here.

          p4sync charset: 'none', credential: 'dead-beef', depotPath: '//depot/project1/tip', format: "jenkins-${env.NODE_NAME}-${env.JOB_NAME}", populate: [$class: 'AutoCleanImpl', delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', path: '/usr/local/bin/p4', threads: '4'], pin: '', quiet: false, replace: true]
          
          Show
          kmott Kyle Mott added a comment - The Jenkinsfile is in there now (as of builds 155 and newer), which are now succeeding. FWIW, here's my p4sync line in my Jenkinsfile. I just changed 'quiet:false', and will see if builds fail the same way as they were yesterday, unable to find the Jenkinsfile. If they do, I will post the logs here. p4sync charset: 'none', credential: 'dead-beef', depotPath: '//depot/project1/tip', format: "jenkins-${env.NODE_NAME}-${env.JOB_NAME}", populate: [$class: 'AutoCleanImpl', delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', path: '/usr/local/bin/p4', threads: '4'], pin: '', quiet: false, replace: true]
          Hide
          p4paul Paul Allen added a comment -

          Parallel sync... I wonder if the sync had not finished, before Jenkins tried to access it?

          Show
          p4paul Paul Allen added a comment - Parallel sync... I wonder if the sync had not finished, before Jenkins tried to access it?
          Hide
          kmott Kyle Mott added a comment -

          I don't think it's running parallel sync (enable: false in 'parallel' block). Should I remove that 'parallel' option entirely?

          Show
          kmott Kyle Mott added a comment - I don't think it's running parallel sync (enable: false in 'parallel' block). Should I remove that 'parallel' option entirely?
          Hide
          p4paul Paul Allen added a comment -

          No need to remove parallel sync. I miss read the enable: option.

          Show
          p4paul Paul Allen added a comment - No need to remove parallel sync. I miss read the enable: option.
          Hide
          kmott Kyle Mott added a comment -

          I think this can be resolved. I did some tweaks to my config, and it appears to be working correctly now. The main adjustment I did was instead of configuring the base workspace as the source for the pipeline script from SCM, I pointed it directly at the Jenkins file so instead of this:

          //depot/project1/tip/... //client_workspace_project1/...

          It ended up looking like this:

          //depot/project1/tip/Jenkinsfile... //client_workspace_project1/Jenkinsfile...

          I also changed the Populate options to "Forced clean & sync", and added a few polling build filters for sub-projects checkins I didn't want to trigger the main parent build. This seems to work now as I would expect, and is quite smooth. Thanks for the pointers Paul Allen.

          Show
          kmott Kyle Mott added a comment - I think this can be resolved. I did some tweaks to my config, and it appears to be working correctly now. The main adjustment I did was instead of configuring the base workspace as the source for the pipeline script from SCM, I pointed it directly at the Jenkins file so instead of this: //depot/project1/tip/... //client_workspace_project1/... It ended up looking like this: //depot/project1/tip/Jenkinsfile... //client_workspace_project1/Jenkinsfile... I also changed the Populate options to "Forced clean & sync", and added a few polling build filters for sub-projects checkins I didn't want to trigger the main parent build. This seems to work now as I would expect, and is quite smooth. Thanks for the pointers Paul Allen .
          Hide
          p4paul Paul Allen added a comment -

          Thanks for the update - I may use your pattern in the docs as an example setup.

          I do something similar for the 'Pipeline script from SCM' option, where I only map the Jenkinsfile in the workspace view. Please note it is better to use the following mapping as the ... wildcard may match other content (and has to do more DB scanning):

          //depot/project1/tip/Jenkinsfile //client_workspace_project1/Jenkinsfile
          
          Show
          p4paul Paul Allen added a comment - Thanks for the update - I may use your pattern in the docs as an example setup. I do something similar for the 'Pipeline script from SCM' option, where I only map the Jenkinsfile in the workspace view. Please note it is better to use the following mapping as the ... wildcard may match other content (and has to do more DB scanning): //depot/project1/tip/Jenkinsfile //client_workspace_project1/Jenkinsfile
          Hide
          heiko_nardmann Heiko Nardmann added a comment -

          I'm not sure whether I shall create a new ticket or continue this one since the subject exactly matches my problem ...

          Currently I'm testing a Python script which shall be used as the trigger script for Perforce.

          On the commandline I just call my script using e.g.

          C:\Python25\python.exe postCommitBuildTrigger.py http://10.11.10.243:8080/ 253175
          

          My problem is that the automatic triggering using /p4/change does not work. I just get

          Oct 10, 2016 3:03:47 PM org.jenkinsci.plugins.p4.trigger.P4Hook doChange
          INFO: Received trigger event: {'p4port': 'perforcetst01:1667', 'change': '253175'}
          

          No probing happens.

          When I use the manual trigger via web UI I get

          Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Hook doChangeSubmit
          INFO: Manual trigger event:
          Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
          INFO: P4: probing: SVKIT_INTEL_NUC
          Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
          INFO: P4: probing: SVKIT_INTEL_NUC-perforcetst01
          Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Trigger poke
          INFO: P4: poking: SVKIT_INTEL_NUC-perforcetst01
          Oct 10, 2016 2:47:42 PM org.jenkinsci.plugins.p4.tasks.CheckoutTask getBuildChange
          INFO: getBuildChange:return:253175
          

          What is the difference between doChange() and doChangeSubmit()?
          Why is there no call to probeJobs() seen in the log for the automatically triggered event?

          My script:

          import sys
          import urllib2
          
          baseUrl = sys.argv[1]
          change = sys.argv[2]
          
          dataDict = { 'change' : change, 'p4port' : "perforcetst01:1667" }
          
          remoteCall = baseUrl + "/p4/change"
          
          requestData = "payload=" + str(dataDict)
          req = urllib2.Request(remoteCall, data=str(requestData), headers={'Content-Type': "application/json"})
          resp = urllib2.urlopen(req)
          html = resp.read()
          resp.close()
          
          Show
          heiko_nardmann Heiko Nardmann added a comment - I'm not sure whether I shall create a new ticket or continue this one since the subject exactly matches my problem ... Currently I'm testing a Python script which shall be used as the trigger script for Perforce. On the commandline I just call my script using e.g. C:\Python25\python.exe postCommitBuildTrigger.py http://10.11.10.243:8080/ 253175 My problem is that the automatic triggering using /p4/change does not work. I just get Oct 10, 2016 3:03:47 PM org.jenkinsci.plugins.p4.trigger.P4Hook doChange INFO: Received trigger event: {'p4port': 'perforcetst01:1667', 'change': '253175'} No probing happens. When I use the manual trigger via web UI I get Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Hook doChangeSubmit INFO: Manual trigger event: Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs INFO: P4: probing: SVKIT_INTEL_NUC Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs INFO: P4: probing: SVKIT_INTEL_NUC-perforcetst01 Oct 10, 2016 2:47:12 PM org.jenkinsci.plugins.p4.trigger.P4Trigger poke INFO: P4: poking: SVKIT_INTEL_NUC-perforcetst01 Oct 10, 2016 2:47:42 PM org.jenkinsci.plugins.p4.tasks.CheckoutTask getBuildChange INFO: getBuildChange:return:253175 What is the difference between doChange() and doChangeSubmit() ? Why is there no call to probeJobs() seen in the log for the automatically triggered event? My script: import sys import urllib2 baseUrl = sys.argv[1] change = sys.argv[2] dataDict = { 'change' : change, 'p4port' : "perforcetst01:1667" } remoteCall = baseUrl + "/p4/change" requestData = "payload=" + str(dataDict) req = urllib2.Request(remoteCall, data=str(requestData), headers={'Content-Type': "application/json"}) resp = urllib2.urlopen(req) html = resp.read() resp.close()
          Hide
          heiko_nardmann Heiko Nardmann added a comment - - edited

          Okay, I've solved my problem: since the script does not provide any credentials its access is mapped to anonymous. On my system that user hasn't been allowed to do anything. After adding Read the trigger script worked fine.

          Now I just have the small "problem" that I do not like the anonymous account. Since we use LDAP I have to look for some kind of "Technical P4 Trigger Account" ...

          Show
          heiko_nardmann Heiko Nardmann added a comment - - edited Okay, I've solved my problem: since the script does not provide any credentials its access is mapped to anonymous . On my system that user hasn't been allowed to do anything. After adding Read the trigger script worked fine. Now I just have the small "problem" that I do not like the anonymous account. Since we use LDAP I have to look for some kind of "Technical P4 Trigger Account" ...
          Hide
          p4paul Paul Allen added a comment -

          You might be able to pass a Jenkins User account and the API Token using basic auth.

          e.g.
          Jenkins -> People -> (user) -> Configure -> API Token -> Show API Token

          then
          https://build:0923840952a90898cf90fe0989@my.jenkins.host.com:8080

          We are in the process of updating the Setup guide to explain the steps better.

          Show
          p4paul Paul Allen added a comment - You might be able to pass a Jenkins User account and the API Token using basic auth. e.g. Jenkins -> People -> (user) -> Configure -> API Token -> Show API Token then https://build:0923840952a90898cf90fe0989@my.jenkins.host.com:8080 We are in the process of updating the Setup guide to explain the steps better.
          Hide
          p4paul Paul Allen added a comment -

          Updated documentation on trigger authorisation.

          Show
          p4paul Paul Allen added a comment - Updated documentation on trigger authorisation.
          Hide
          pyrocks Mor L added a comment -

          Hi,

          After not being able to successfully poll perforce directly from a pipeline job (http://stackoverflow.com/questions/41260552/jenkins-pipeline-poll-perforce), I tried setting up the automatic trigger according to the "Triggering" section in https://github.com/jenkinsci/p4-plugin/blob/master/SETUP.md
          I have a similar issue which was reported above - I can see the trigger being received in the System log - but poking the job does nothing:

          Dec 21, 2016 10:59:21 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange
          Received trigger event: {change:1239,p4port:"perfcm:1668"}
          Dec 21, 2016 10:59:21 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
          P4: probing: pipeline_perforce_polling
          Dec 21, 2016 10:59:21 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke
          P4: poking: pipeline_perforce_polling
          

          nothing in the log beyond this point.

          p.s I'm running on Jenkins 2.7.4 - is it resolved in 2.8?

          Thanks,
          Mor

          Show
          pyrocks Mor L added a comment - Hi, After not being able to successfully poll perforce directly from a pipeline job ( http://stackoverflow.com/questions/41260552/jenkins-pipeline-poll-perforce ), I tried setting up the automatic trigger according to the "Triggering" section in https://github.com/jenkinsci/p4-plugin/blob/master/SETUP.md I have a similar issue which was reported above - I can see the trigger being received in the System log - but poking the job does nothing: Dec 21, 2016 10:59:21 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange Received trigger event: {change:1239,p4port: "perfcm:1668" } Dec 21, 2016 10:59:21 AM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs P4: probing: pipeline_perforce_polling Dec 21, 2016 10:59:21 AM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke P4: poking: pipeline_perforce_polling nothing in the log beyond this point. p.s I'm running on Jenkins 2.7.4 - is it resolved in 2.8? Thanks, Mor
          Hide
          heiko_nardmann Heiko Nardmann added a comment - - edited

          Which credentials does your anonymous user have? It it able to list+read the jobs?

          Show
          heiko_nardmann Heiko Nardmann added a comment - - edited Which credentials does your anonymous user have? It it able to list+read the jobs?
          Hide
          pyrocks Mor L added a comment -

          Hi, thanks for the response.
          I do not use the anonymous user but a crumb as shown in the documentation.
          The user I use to get the crumb has the build permission, and since the jenkins log shows the request is received and the relevant job found I thought the role of the user ends there.
          I will play around with the permissions tomorrow and update.

          Show
          pyrocks Mor L added a comment - Hi, thanks for the response. I do not use the anonymous user but a crumb as shown in the documentation. The user I use to get the crumb has the build permission, and since the jenkins log shows the request is received and the relevant job found I thought the role of the user ends there. I will play around with the permissions tomorrow and update.
          Hide
          pyrocks Mor L added a comment -

          Actually, the same happens when I trigger the job manually using the $jenkinsurl/p4 while connected as an admin user.

          Show
          pyrocks Mor L added a comment - Actually, the same happens when I trigger the job manually using the $jenkinsurl/p4 while connected as an admin user.

            People

            Assignee:
            p4paul Paul Allen
            Reporter:
            kmott Kyle Mott
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: