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

Expose readonly type option for Manual workspaces

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • p4-plugin
    • None
    • Jenkins 2.30 // P4 Plugin 1.4.8

      According to https://www.perforce.com/perforce/r16.1/manuals/cmdref/p4_client.html , a client can be optionally set to type readonly to avoid automated builds fragmenting and bloating the server's db.have file. There are other benefits to using readonly-type clients - from what I understand the readonly client db files are not journaled so they won't be transmitted between replicas when they change.

      Using readonly clients for our Jenkins builds would likely solve an issue we have where one of our replicas in France gets hammered with nightly builds which makes our replica in the US completely unusable for an hour or more due to the db.have file being locked while our replica catches up with all of the pointless updates from the French replica.

          [JENKINS-39753] Expose readonly type option for Manual workspaces

          Tristan Lewis added a comment -

          I have realized that the client type field is not exposed at all in the latest version of the P4Java API, so there's no way for this to be implemented currently.

          Tristan Lewis added a comment - I have realized that the client type field is not exposed at all in the latest version of the P4Java API, so there's no way for this to be implemented currently.

          Paul Allen added a comment -

          It is now supported in p4java 2017.1

          Planning to add dropdown to Manual Workspace Impl, do you need it on any others?

          Paul Allen added a comment - It is now supported in p4java 2017.1 Planning to add dropdown to Manual Workspace Impl, do you need it on any others?

          Tristan Lewis added a comment -

          That's great news Paul! Manual Workspace Impl is the only place we'd need it exposed.

          Tristan Lewis added a comment - That's great news Paul! Manual Workspace Impl is the only place we'd need it exposed.

          Code changed in jenkins
          User: Paul Allen
          Path:
          src/main/java/org/jenkinsci/plugins/p4/workspace/ManualWorkspaceImpl.java
          src/main/java/org/jenkinsci/plugins/p4/workspace/WorkspaceSpec.java
          src/main/java/org/jenkinsci/plugins/p4/workspace/WorkspaceSpecType.java
          src/main/resources/org/jenkinsci/plugins/p4/workspace/WorkspaceSpec/config.jelly
          src/test/java/org/jenkinsci/plugins/p4/DefaultEnvironment.java
          src/test/java/org/jenkinsci/plugins/p4/client/WorkspaceTest.java
          http://jenkins-ci.org/commit/p4-plugin/91e3a3c8284d2bb84061f1afe2d16f63aeb95ee7
          Log:
          Manual Workspace support for READONLY and PARTITIONED.

          Change Type to Enum.
          JENKINS-39753

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Paul Allen Path: src/main/java/org/jenkinsci/plugins/p4/workspace/ManualWorkspaceImpl.java src/main/java/org/jenkinsci/plugins/p4/workspace/WorkspaceSpec.java src/main/java/org/jenkinsci/plugins/p4/workspace/WorkspaceSpecType.java src/main/resources/org/jenkinsci/plugins/p4/workspace/WorkspaceSpec/config.jelly src/test/java/org/jenkinsci/plugins/p4/DefaultEnvironment.java src/test/java/org/jenkinsci/plugins/p4/client/WorkspaceTest.java http://jenkins-ci.org/commit/p4-plugin/91e3a3c8284d2bb84061f1afe2d16f63aeb95ee7 Log: Manual Workspace support for READONLY and PARTITIONED. Change Type to Enum. JENKINS-39753

          Paul Allen added a comment -

          Ready for release.

          Paul Allen added a comment - Ready for release.

          Paul Allen added a comment -

          Released in 1.7.0

          Paul Allen added a comment - Released in 1.7.0

          Tristan Lewis added a comment -

          Hey p4paul - I've gotten around to trying the new Type option for ManualWorkspaceImpl and while I can set it to READONLY in the job configuration, it doesn't seem to take affect when it writes out the workspace to perforce. To test this, I deleted the workspace associated with a job (since a workspace type cannot be changed after it's created), used the Jenkins UI to change the manual workspace type to READONLY, and then re-ran the job.

          The workspace that gets created with the new job configuration does not have a Type field, and I see no contents in my readonly clients directory on the p4d server. Am I doing something wrong?

          Tristan Lewis added a comment - Hey p4paul - I've gotten around to trying the new Type option for ManualWorkspaceImpl and while I can set it to READONLY in the job configuration, it doesn't seem to take affect when it writes out the workspace to perforce. To test this, I deleted the workspace associated with a job (since a workspace type cannot be changed after it's created), used the Jenkins UI to change the manual workspace type to READONLY, and then re-ran the job. The workspace that gets created with the new job configuration does not have a Type field, and I see no contents in my readonly clients directory on the p4d server. Am I doing something wrong?

          Paul Allen added a comment -

          Here is a simple Pipeline script using 'readonly':

          node() {
              checkout([$class: 'PerforceScm', 
                  credential: 'graph1234', 
                  populate: [$class: 'AutoCleanImpl', 
                      delete: true, 
                      modtime: false, 
                      pin: '', 
                      quiet: true, 
                      replace: true], 
                  workspace: [$class: 'ManualWorkspaceImpl', 
                      charset: 'none', 
                      name: 'jenkins-${NODE_NAME}-${JOB_NAME}', 
                      pinHost: false, 
                      spec: [allwrite: false, 
                          backup: false, 
                          clobber: false, 
                          compress: false, 
                          line: 'LOCAL', 
                          locked: false, 
                          modtime: false, 
                          rmdir: false, 
                          serverID: '', 
                          streamName: '//p4-perl/main', 
                          type: 'READONLY', 
                          view: '']
                      ]
                  ])
          }
          

          and the verified with:

          p4 client -o jenkins-achilles-pipeReadOnly
          
          Client:	jenkins-achilles-pipeReadOnly
          
          Update:	2017/06/08 14:02:58
          
          Access:	2017/06/08 14:02:58
          
          Owner:	p4jtestsuper
          
          Root:	/home/pallen/slave-mac/workspace/pipeReadOnly
          
          Options:	noallwrite clobber nocompress unlocked nomodtime normdir
          
          SubmitOptions:	submitunchanged
          
          LineEnd:	local
          
          Stream:	//p4-perl/main
          
          Type:	readonly
          
          View:
          	//p4-perl/main/... //jenkins-achilles-pipeReadOnly/...
          
          

          Paul Allen added a comment - Here is a simple Pipeline script using 'readonly': node() { checkout([$class: 'PerforceScm' , credential: 'graph1234' , populate: [$class: 'AutoCleanImpl' , delete: true , modtime: false , pin: '', quiet: true , replace: true ], workspace: [$class: 'ManualWorkspaceImpl' , charset: 'none' , name: 'jenkins-${NODE_NAME}-${JOB_NAME}' , pinHost: false , spec: [allwrite: false , backup: false , clobber: false , compress: false , line: 'LOCAL' , locked: false , modtime: false , rmdir: false , serverID: '', streamName: ' //p4-perl/main' , type: 'READONLY' , view: ''] ] ]) } and the verified with: p4 client -o jenkins-achilles-pipeReadOnly Client: jenkins-achilles-pipeReadOnly Update: 2017/06/08 14:02:58 Access: 2017/06/08 14:02:58 Owner: p4jtestsuper Root: /home/pallen/slave-mac/workspace/pipeReadOnly Options: noallwrite clobber nocompress unlocked nomodtime normdir SubmitOptions: submitunchanged LineEnd: local Stream: //p4-perl/main Type: readonly View: //p4-perl/main/... //jenkins-achilles-pipeReadOnly/...

          Paul Allen added a comment -

          I used a 2017.1 P4D and had set the 'client.readonly.dir' configurable:

          client.readonly.dir=clients.readonly
          

          Paul Allen added a comment - I used a 2017.1 P4D and had set the 'client.readonly.dir' configurable: client.readonly.dir=clients.readonly

            p4paul Paul Allen
            tr1z Tristan Lewis
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: