2

In continuation to jenkins-pipeline-syntax-for-p4sync - I am not able to get the "Poll SCM" option work for my pipeline job. Here is my configuration:

  1. "Poll SCM" is checked and set to poll every 10 minutes
  2. Pipeline script contains the following:

node ('some-node') // not actual value
{
    stage ('checkout')
    {
        checkout([
            $class: 'PerforceScm', 
            credential: '11111111-1111-1111-1111-11111111111', // not actual value
            populate: [
                $class: 'AutoCleanImpl', 
                delete: true, 
                modtime: false, 
                parallel: [
                    enable: false, 
                    minbytes: '1024', 
                    minfiles: '1', 
                    path: '/usr/local/bin/p4', 
                    threads: '4'
                    ], 
                pin: '', 
                quiet: true, 
                replace: true
                ], 
            workspace: [
                $class: 'ManualWorkspaceImpl', 
                charset: 'none', 
                name: 'jenkins-${NODE_NAME}-${JOB_NAME}', 
                pinHost: false, 
                spec: [
                    allwrite: false, 
                    clobber: false, 
                    compress: false, 
                    line: 'LOCAL', 
                    locked: false, 
                    modtime: false, 
                    rmdir: false, 
                    streamName: '', 
                    view: '//Depot/subfolder... //jenkins-${NODE_NAME}-${JOB_NAME}/...' // not actual value
                    ]
                ]
            ]
        )
    }

stage ('now do something')
{
    sh 'ls -la'
}
}
  1. Ran the job manually once

Still, polling does not work and job does not have a "Perforce Software Polling Log" link like a non-pipelined job has when configuring the perforce source and Poll SCM in the GUI. It's like the PerforceSCM is missing a poll: true setting - or i'm doing something wrong.

Currently I have a workaround in which I poll perforce in a non-pipelined job which triggers a pipelined job, but then I have to pass the changelists manually and I would rather the pipeline job to do everything.

edit: versions

jenkins - 2.7.4
P4 plugin - 1.4.8
Pipeline plugin - 2.4
Pipeline SCM Step plugin - 2.2

Community
  • 1
  • 1
Pyrocks
  • 401
  • 3
  • 14

2 Answers2

1

If you go to the Groovy snippet generator and check the "include in polling" checkbox, you'll see that the generated code includes a line item for it:

checkout([
            poll: true,

As an aside, you may run into problems at the moment using ${NODE_NAME} in your workspace name. The polling runs on the master, so it might not properly find the change number of your previous build. If that's the case, I know a fix for it should be coming shortly.

Peter McNab
  • 1,031
  • 1
  • 10
  • 11
  • Thanks for replying. 1. in the snippet generator, when the SCM is "Perforce software" - even when "include in polling" is checked - it does not generate a "poll: true" in the snippet. So I'm not sure it is supported. 2. Can you link to the relevant issue with the workspaces - for tracking purposes? – Pyrocks Dec 22 '16 at 08:40
  • It just hit me that the workspace name not working correctly is because the snippet is generated with single quotes (') for strings. If you use double quotes (") instead you will get the correct workspace. That's a known limitation in pipeline/groovy. - see "String Interpolation" section in [link](https://jenkins.io/doc/book/pipeline/jenkinsfile) – Pyrocks Dec 22 '16 at 14:50
  • @Pyrocks "poll: true" is the default value. Try to uncheck it, and you will see "poll: false" is being generated. – sqybi Jan 15 '19 at 05:04
0

After updating all the plugins to latest (as of this post date) and restarting the jenkins server - the polling appears to be working with the exact same configuration (job now has the poll log link). I'm not sure what exactly resolved the issue - but I consider it resolved.

Pyrocks
  • 401
  • 3
  • 14