-
Bug
-
Resolution: Unresolved
-
Blocker
-
Powered by SuggestiMate
I have succeeded to trigger Freestyle project, but I couldn't trigger pipelile project when 'Perforce Triggered Build' is checked.
[JENKINS-70597] perforce plugin doesn't trigger Pipline project
You are correct in saying that the multibranch pipeline uses p4/event endpoint. However, OP is asking about Pipeline job
I'm able to trigger a freestyle job using p4/change endpoint.
I'm able to trigger a multibranch pipeline using p4/event endpoint.
Similar to OP, I'm unable to trigger a Pipeline job (Pipeline script from SCM setup) using either of those endpoints.
All these projects use the same Perforce server and the same credential.
I can see the pipeline job (test_p4_trigger_pipeline) {}mentioned in the Jenkins logs but it doesn't trigger it. I also don't see {{P4: poking:... }}for this pipeline.
...
INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange
Received trigger event for: <P4PORT>
...
INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs
P4: probing: test_p4_trigger_pipeline
...
Hi lobopraveen - Thanks for the confirmation.
What version of Jenkins and P4Plugin are you using?
For me this works:
curl --user perforce:110143578ecaf3ad76bde7bad656d1b9a5 --header 'Content-Type: application/json' --request POST --data "payload={change:200,p4port:\"localhost:1666\"}" http://192.168.1.128:8080/p4/change
And triggers my pipeline job that is defined as:
The script I am using is:
pipeline { agent any } stages { stage("Test") { steps { script { echo "In script." checkout perforce(credential: 'JenkinsMaster', populate: autoClean(delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', threads: '4'], pin: '', quiet: true, replace: true, tidy: false), workspace: manualSpec(charset: 'none', name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}', pinHost: false, spec: clientSpec(allwrite: false, backup: false, clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/project1/main/... //${P4_CLIENT}/...'))) sh 'ls' } } } } }
In the Jenkins log I see:
Received trigger event for: localhost:1666
Jun 08, 2023 2:34:25 PM FINE org.jenkinsci.plugins.p4.trigger.P4HookP4: trying: GroovyIntegTest
Jun 08, 2023 2:34:25 PM FINE org.jenkinsci.plugins.p4.trigger.P4HookP4: trigger not set: GroovyIntegTest
Jun 08, 2023 2:34:25 PM FINE org.jenkinsci.plugins.p4.trigger.P4Hoo
P4: probing: TriggeredBuild
Jun 08, 2023 2:34:25 PM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger pokeP4: poking: TriggeredBuild
Jun 08, 2023 2:34:25 PM FINER org.jenkinsci.plugins.p4.PerforceScmP4:
I am using Jenkins Jenkins 2.387.3 and p4-plugin 1.14.1.
Can you see how your test differs to mine?
Hi p4karl - We are using Jenkins version 2.375.4.2-rolling and p4-plugin version 1.14.1. We can trigger a Freestyle job using below curl cmd; however unable to trigger a regular pipeline job using the same cmd. The screenshot below is for the pipeline job.
curl --header 'Content-Type: application/json' --user <user>:<pwd> --request POST --data "payload={change:200,p4port:\"<P4PORT>"}" https://<JenkinsUrl>/xxxx/p4/change
p4karl The test machine I'm using has Jenkins 2.303.3 and p4 plugin version 1.11.6. The pipeline I'm testing with uses Pipeline script from SCM option for the Pipeline > Definition where I provide the credentials, set Streams as the Workspace behaviour and set correct stream (//depot/stream-name) in the stream codeline etc.
For every commit, my test setup is sending two hooks - 1) p4/change and 2) p4/event so that I can test freestyle, pipeline, and multibranch pipelines. As mentioned earlier, only the pipeline type seems to be not working.
From reading the Jenkins log, it appears that when a hook comes in, the plugin starts probing all pipelines because I see a handful of P4: probing: <pipeline-name> and only one two such pipelines I see a following up P4: poking: <pipeline-name>. Then I see a bunch of P4: Creating stream client: lines but this is not always same amount - they range from 2 such lines to like 10+ sometimes. I also noticed getBuildChange:return:<number> occasionally and it reports the same number for a while. You can observe these in the log below. I wish the plugin logged additional context with those messages.
I provided anonymized log below. I also noticed that some of P4: Creating stream client: ... take close to 10 minutes. I suspect these might not be using lightweight checkout but the multibranch pipelines should always default to lightweight checkout right? It'd be a little easy to understand the log if the plugin printed the pipeline/job name.
<DATE> 10:27:02 PM INFO org.jenkinsci.plugins.p4.tasks.CheckoutTask getBuildChange getBuildChange:return:123456 <DATE> 10:40:03 PM INFO org.jenkinsci.plugins.p4.trigger.P4Hook doChange Received trigger event for: <server>:<port> <DATE> 10:40:03 PM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs P4: probing: PIPELINE-1-THAT-TRIGGERS <DATE> 10:40:03 PM INFO org.jenkinsci.plugins.p4.trigger.P4Trigger poke P4: poking: PIPELINE-1-THAT-TRIGGERS <DATE> 10:40:04 PM INFO org.jenkinsci.plugins.p4.trigger.P4Hook probeJobs P4: probing: PIPELINE-2-THAT-DOES-NOT-TRIGGER <DATE> 10:40:06 PM INFO org.jenkinsci.plugins.p4.workspace.StreamWorkspaceImpl setClient P4: Creating stream client: jenkinsTemp-21c2300c-f6d5-4ed9-9551-6c978bb99f39 <DATE> 10:40:11 PM INFO org.jenkinsci.plugins.p4.workspace.StreamWorkspaceImpl setClient P4: Creating stream client: jenkinsTemp-aa9c88de-1a8a-48c8-a05a-063c55415085 <truncated multiple similar lines> <DATE> 10:58:18 PM INFO org.jenkinsci.plugins.p4.workspace.StreamWorkspaceImpl setClient P4: Creating stream client: jenkinsTemp-85f9f9bc-e95b-4c4a-94ca-74e05f5cd34d <DATE> 10:58:19 PM INFO org.jenkinsci.plugins.p4.tasks.CheckoutTask getBuildChange getBuildChange:return:123456 <DATE> 12:14:00 AM INFO org.jenkinsci.plugins.p4.workspace.StreamWorkspaceImpl setClient P4: Creating stream client: jenkinsTemp-1f1c8fd3-94ed-47a8-a915-afa858717d16 <DATE> 12:14:02 AM INFO org.jenkinsci.plugins.p4.tasks.CheckoutTask getBuildChange getBuildChange:return:123456
Thank you for your time!
Hi hovhannisyan
I think for multibranch you now need to use the p4/event endpoint:
https://www.perforce.com/manuals/jenkins/Content/P4Jenkins/multibranch-pipeline-setup.html?Highlight=event#MultiBranch_trigger_SCM_events
Regards,
Karl