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

P4Groovy - P4Groovy fails to run on agent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • p4-plugin
    • Master OS: Windows Server 2012 R2 (build 9600)
      Agent OS: CentOS 7.4.1708 (Core)
      Jenkins: 2.150.1
      P4 Plugin: 1.9.5

      Duplication

      1. Go to an agent's script console (http://<jenkins>/computer/<agent node>/script)
      2. Run this script
        import org.jenkinsci.plugins.p4.workspace.StreamWorkspaceImpl;
        import org.jenkinsci.plugins.p4.groovy.P4Groovy;
        
        def ws = new StreamWorkspaceImpl('none', false, '//Stream_Depot/Main', 'job1-temp-branch1')
        def p4 = new P4Groovy('credential', null, ws, new FilePath(new File('workspace')))
        def result = p4.run('status')

        Error: 'java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong.'

      Can also be duplicated by running the following script in a Jenkinsfile

      def ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: env.JOB_NAME + '-temp-' + env.BRANCH_NAME, pinHost: false, streamName: '//Stream_Depot/' + env.BRANCH_NAME] def p4 = p4(credential: 'credential', workspace: ws) def result = p4.run('streams')

      Expected Result

      I can use P4Groovy on an agent with no errors.

      Workaround

      Run P4Groovy commands in a separate stage running on the master. If data is needed, use Environment Variables to transfer variables to agent.

            Unassigned Unassigned
            dthomash Dylan H
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: