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

NPE in parseProjectPath when attempting to create Perforce workspace without a mapping

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • p4-plugin
    • None
    • Jenkins ver. 1.609.2 perforce-plugin ver. 1.3.35

      Before upgrading from 1.3.33 to 1.3.35 Jenkins was able to create a Perforce workspace when it didn't already exist, however after upgrading to 1.3.35 I get the following NPE:

      My Perforce configuration has a username listed, but the password is blank, and not necessary.

      Building in workspace /path/to/workspace
      Using master perforce client: workspace_name
      [ltconeng] $ /corp/tools/perforce/2011.1/cli/p4 workspace -o workspace_name
      Changing P4 Client Root to: /path/to/workspace
      Caught exception in perforce-plugin. nulljava.lang.NullPointerException
      	at hudson.plugins.perforce.PerforceSCM.parseProjectPath(PerforceSCM.java:2502)
      	at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1710)
      	at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1602)
      	at hudson.plugins.perforce.PerforceSCM.checkout(PerforceSCM.java:907)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1274)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:609)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:531)
      	at hudson.model.Run.execute(Run.java:1738)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:381)
      ERROR: Caught exception in perfoce-plugin. null
      

          [JENKINS-30373] NPE in parseProjectPath when attempting to create Perforce workspace without a mapping

          Rob Petti added a comment -

          Please post your view spec. It looks like it's having issues parsing it.

          Rob Petti added a comment - Please post your view spec. It looks like it's having issues parsing it.

          Justin Wagner added a comment -

          That is likely the issue. Initially the viewspec is empty (currently) and then our script determines what it should be (based on what project is being ran), and updates the workspace accordingly.

          How do you suggest we handle this properly?

          Justin Wagner added a comment - That is likely the issue. Initially the viewspec is empty (currently) and then our script determines what it should be (based on what project is being ran), and updates the workspace accordingly. How do you suggest we handle this properly?

          Rob Petti added a comment -

          Here are a few options:

          • Disable the perforce plugin entirely, and do all of your syncing and workspace management via scripts.
          • Disable perforce workspace generation and management in the job config, and manage them separately (either manually or via scripts).
          • Parameterize your view spec based on the job name or some other job parameter, ie: "//depot/${JOB_NAME}/... //workspace/..."
          • Use scripts or a plugin such as Job DSL to generate your Jenkins jobs with the correct perforce configuration, so that each job is correctly configured prior to it being executed.

          Apart from that, you simply cannot use the perforce plugin without providing a workspace view for it to use. What would be the point?

          Rob Petti added a comment - Here are a few options: Disable the perforce plugin entirely, and do all of your syncing and workspace management via scripts. Disable perforce workspace generation and management in the job config, and manage them separately (either manually or via scripts). Parameterize your view spec based on the job name or some other job parameter, ie: "//depot/${JOB_NAME}/... //workspace/..." Use scripts or a plugin such as Job DSL to generate your Jenkins jobs with the correct perforce configuration, so that each job is correctly configured prior to it being executed. Apart from that, you simply cannot use the perforce plugin without providing a workspace view for it to use. What would be the point?

          Justin Wagner added a comment -

          The point of using the plugin is to get build triggers based on changes in the repository.

          This NPE is only on the initial condition when our script hasn't configured the viewspec yet.

          Is there some non-null value I can put in that field that would allow us to get past this NPE?

          The issue here is that the viewspec is a dynamic thing that our coders can change at any time, and we have a system for how they are to document and submit that via a file in Perforce, which we then parse and use to configure the viewspec of the automated build job.

          Suggestions 1 & 2 are out of the question, as we want build triggers based on repository changes. Suggestion 3 is too simplistic and not feasible. I am not familiar with Job DSL, but it seems like an overkill solution for this simple problem.

          Justin Wagner added a comment - The point of using the plugin is to get build triggers based on changes in the repository. This NPE is only on the initial condition when our script hasn't configured the viewspec yet. Is there some non-null value I can put in that field that would allow us to get past this NPE? The issue here is that the viewspec is a dynamic thing that our coders can change at any time, and we have a system for how they are to document and submit that via a file in Perforce, which we then parse and use to configure the viewspec of the automated build job. Suggestions 1 & 2 are out of the question, as we want build triggers based on repository changes. Suggestion 3 is too simplistic and not feasible. I am not familiar with Job DSL, but it seems like an overkill solution for this simple problem.

          Rob Petti added a comment -

          How does your script configure the viewspec? Unless it's actually changing the job configuration in Jenkins, what you are proposing won't work.

          Rob Petti added a comment - How does your script configure the viewspec? Unless it's actually changing the job configuration in Jenkins, what you are proposing won't work.

          Justin Wagner added a comment - - edited

          I have "Let Jenkins Create Workspace" enabled, but "Let Jenkins Manage Workspace View" disabled.

          Our script is updating the viewspec through directly executing the p4 command line calls to update the viewspec on the Perforce server.

          We've been using the plugin for some time now, and I was always manually creating the workspaces in Perforce to get things started. I just recently enabled "Let Jenkins Create Workspace" to not have to do that part by hand, but I still wanted to be able to manage the viewspec from our script, so I left the "Let Jenkins Manage Workspace View" configuration disabled.

          I know that the underlying "p4 client" command to create a workspace depends on a view spec, so I see the problem here.

          I am planning to work around this, by having the initial value of the viewspec be some simple valid viewspec that will work initially, but immediately be over written when our script edits the workspace.

          Justin Wagner added a comment - - edited I have "Let Jenkins Create Workspace" enabled, but "Let Jenkins Manage Workspace View" disabled. Our script is updating the viewspec through directly executing the p4 command line calls to update the viewspec on the Perforce server. We've been using the plugin for some time now, and I was always manually creating the workspaces in Perforce to get things started. I just recently enabled "Let Jenkins Create Workspace" to not have to do that part by hand, but I still wanted to be able to manage the viewspec from our script, so I left the "Let Jenkins Manage Workspace View" configuration disabled. I know that the underlying "p4 client" command to create a workspace depends on a view spec, so I see the problem here. I am planning to work around this, by having the initial value of the viewspec be some simple valid viewspec that will work initially, but immediately be over written when our script edits the workspace.

          Justin Wagner added a comment -

          If there is anything that could be improved here, it would be to notify the user with a better error message that they need to set a valid viewspec.

          Justin Wagner added a comment - If there is anything that could be improved here, it would be to notify the user with a better error message that they need to set a valid viewspec.

          Rob Petti added a comment -

          How about something like the following?

          //depot/pathtononexistentlocation/... //workspace/...
          

          It's a valid mapping, but shouldn't sync anything down.

          Rob Petti added a comment - How about something like the following? //depot/pathtononexistentlocation/... //workspace/... It's a valid mapping, but shouldn't sync anything down.

          Justin Wagner added a comment -

          Perfect, thanks.

          Justin Wagner added a comment - Perfect, thanks.

            Unassigned Unassigned
            jwagner Justin Wagner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: