1

I have a Jenkins2 Pipeline where I sync with:

p4sync charset: 'none',
       stream: myStream,
       format: clientName,
       populate: [$class: 'ForceCleanImpl', have: true, pin: '', quiet: true]

where myStream is a parameter passed to the Jenkins Build Job.

We do have streams with several GB of data and for all of them I am only interested in a particular subdirectory which only has several MB.

Is there any way of narrowing the Client View to that single subdirectory for any passed in stream?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
abergmeier
  • 13,224
  • 13
  • 64
  • 120
  • 1
    It seems like your stream definitions are too broad, perhaps? Maybe you could define virtual child streams which contain only the subset of the code which is necessary for your build? Then build the more process child stream rather than the broader parent stream. – Bryan Pendleton Jan 26 '17 at 14:25
  • Doing anything manually is a NoNo. – abergmeier Jan 26 '17 at 15:37

2 Answers2

2

As I mentioned in the comment on the first answer, while you can use a classic depot view to get content out of a stream depot, you will run into problems if files are being imported from other locations.

The correct way to handle this is with Perforce's Virtual Streams which allow you to make a filtered view.

Among the benefits are that your stream definition and virtual stream are defined in the same place, rather than running the risk of changing your stream and forgetting to make a change to the Jenkins configuration

Peter McNab
  • 1,031
  • 1
  • 10
  • 11
  • 1
    True but we use perforce streams straight forward without any content remapping. – abergmeier Jan 26 '17 at 21:40
  • 1
    So it's a straightforward usage for you, but I wanted to chime in and just say there are some risks to that choice. I still think using the same place to define your stream and your "build" virtual stream is better than scattering configuration around too many places. – Peter McNab Jan 26 '17 at 22:11
0

Basically using the Syntax of Jenkins Pipeline Syntax for "p4sync" works fine:

checkout([
  $class: 'PerforceScm', 
  credential: 'phooey1666', 
  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: true, 
      clobber: false, 
      compress: false, 
      line: 'LOCAL', 
      locked: false, 
      modtime: false, 
      rmdir: false, 
      streamName: '',
      view: '''
        //depot/... //jenkins-${NODE_NAME}-${JOB_NAME}/...
        -//depot/tests/... //jenkins-${NODE_NAME}-${JOB_NAME}/tests/...'''
    ]
  ]
])
abergmeier
  • 13,224
  • 13
  • 64
  • 120
  • This only works if some of the content you want out of the stream is not being imported from somewhere else. If so, you have to manually manage that in the jenkins config. – Peter McNab Jan 26 '17 at 21:21