2
votes

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

2

2 Answers

1
votes

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.

0
votes

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.