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

Missing DSL Methods for Perforce Plugin in Jenkins Job DSL

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • p4-plugin
    • Version Job DSL plugin : 1.91
      plugin p4 : 1.17.0
      Jenkins Version : 2.492.2
      OS :

      Hello,

      I am encountering issues when trying to create freestyle jobs using Job DSL scripts for the Perforce plugin in Jenkins. Some expected methods seem to be missing or undefined in the DSL, making it impossible to configure certain options properly.

      - Workspace Configuration Issues

      • Only the manual() method works for defining a workspace.
      • Methods for other workspace types, such as static (spec) or template, seem to be missing or not recognized.
      • Example error when attempting to use a static workspace: 
        unexpected token: static @ line 166, column 21.
        static(client_spec)

      - Missing Populate Options in DSL

      • The populate options (such as sync only, auto sync, etc.) are not available in the DSL configuration.
      • I couldn't find a way to configure clean workspace, force sync, or other p4 populate options via Job DSL.

      - Expected Behavior

      The DSL should provide methods to configure all workspace types (manual, static, template, auto) and allow defining populate options such as sync only and force sync.

      - Steps to Reproduce

      1. Install the Perforce Plugin in Jenkins.
      1. Try to define a freestyle job with a static workspace or populate options using Job DSL.
      1. The only working method is manual(), while other workspace definitions fail.

      Could you please confirm whether these features are missing from the Job DSL support, or if there is an alternative way to configure them?

      Thanks in advance for your help!

      Best regards,

      Esdras

          [JENKINS-75497] Missing DSL Methods for Perforce Plugin in Jenkins Job DSL

          Karl Wirth added a comment -

          Hi esdras - As far as I know the Job DSL plugin is not something we actively code for. Does this have an overlap with the Jenkinsfile mechanism? That is an interface we support. For example:

          Which would generate code similar to:

          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: staticSpec(charset: 'none', name: 'MYSTATIC_WS', pinHost: false)) 

           

           

          Karl Wirth added a comment - Hi esdras - As far as I know the Job DSL plugin is not something we actively code for. Does this have an overlap with the Jenkinsfile mechanism? That is an interface we support. For example: Which would generate code similar to: 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: staticSpec(charset: ' none ', name: ' MYSTATIC_WS', pinHost: false ))    

          Esdras added a comment -

          Hi Karl,

          Thank you for your response! I understand that the Perforce plugin supports Jenkins pipelines, but in my case, I am using Freestyle jobs with Job DSL scripts, not declarative pipelines.

          The issue I am facing is that, in Job DSL, only the manual() method seems to work for defining a workspace, while other workspace types (such as staticSpec, template, or specFile) do not have corresponding DSL methods. Additionally, I couldn't find any methods to define populate options like autoClean, syncOnly, or forceClean.

          Does Perforce officially support Job DSL configurations for freestyle jobs? If not, is there a recommended workaround to achieve this without switching to a pipeline job?

          Thanks you for you help!

          Esdras

          Esdras added a comment - Hi Karl, Thank you for your response! I understand that the Perforce plugin supports Jenkins pipelines, but in my case, I am using Freestyle jobs with Job DSL scripts , not declarative pipelines. The issue I am facing is that, in Job DSL, only the manual() method seems to work for defining a workspace, while other workspace types (such as staticSpec, template, or specFile ) do not have corresponding DSL methods. Additionally, I couldn't find any methods to define populate options like autoClean , syncOnly , or forceClean . Does Perforce officially support Job DSL configurations for freestyle jobs? If not, is there a recommended workaround to achieve this without switching to a pipeline job? Thanks you for you help! Esdras

          Karl Wirth added a comment -

          Hi esdras - I'll check with the development team and one of us will get back to you.

          Karl Wirth added a comment - Hi esdras - I'll check with the development team and one of us will get back to you.

            Unassigned Unassigned
            esdras Esdras
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: