• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • p4-plugin
    • None
    • P4 plugin 1.3.1

      When using the workflow plugin.

      This syncs the workspace to changelist foo:

      checkout $class: 'PerforceScm', populate [$class: 'ForceCleanImpl', pin: 'foo', ...

      This always syncs the workspace to the head revision:

      checkout $class: 'PerforceScm', populate [$class: 'CheckOnlyImpl', pin: 'foo', ...

          [JENKINS-30596] Pin changelist not working with CheckOnlyImpl

          Paul Allen added a comment -

          I'd almost forgotten about this mode, CheckOnly was not designed to sync code (only preview). However, with updates and changes over the past year, it might have changed in behaviour.

          The pin field is set to null and not passing down pin, so that part is easy to fix. Are you using this? I'm trying to remember who asked for it and if it might be redundant.

          @DataBoundConstructor
          	public CheckOnlyImpl(boolean have, boolean force, boolean modtime, boolean quiet,
          			String pin) {
          		super(false, false, false, quiet, null);
          	}
          

          Paul Allen added a comment - I'd almost forgotten about this mode, CheckOnly was not designed to sync code (only preview). However, with updates and changes over the past year, it might have changed in behaviour. The pin field is set to null and not passing down pin, so that part is easy to fix. Are you using this? I'm trying to remember who asked for it and if it might be redundant. @DataBoundConstructor public CheckOnlyImpl( boolean have, boolean force, boolean modtime, boolean quiet, String pin) { super ( false , false , false , quiet, null ); }

          Paul Allen added a comment -

          Found the behaviour in ClientHelper...

          		if (populate instanceof CheckOnlyImpl) {
          			syncHaveList(files, populate);
          		} else {
          			syncFiles(files, populate);
          		}
          

          Seems it was designed to only check the latest revision and run a sync -k...

          	/**
          	 * Test to see if workspace is at the latest revision.
          	 *
          	 * @throws Exception
          	 */
          	private boolean syncHaveList(List<IFileSpec> files, Populate populate)
          			throws Exception {
          		// Preview (sync -k)
          		SyncOptions syncOpts = new SyncOptions();
          		syncOpts.setClientBypass(true);
          		syncOpts.setQuiet(populate.isQuiet());
          
          		List<IFileSpec> syncMsg = iclient.sync(files, syncOpts);
          		validateFileSpecs(syncMsg, "file(s) up-to-date.",
          				"file does not exist", "no file(s) as of that date");
          
          		for (IFileSpec fileSpec : syncMsg) {
          			if (fileSpec.getOpStatus() != FileSpecOpStatus.VALID) {
          				String msg = fileSpec.getStatusMessage();
          				if (msg.contains("file(s) up-to-date.")) {
          					return true;
          				}
          			}
          		}
          		return false;
          	}
          

          Paul Allen added a comment - Found the behaviour in ClientHelper... if (populate instanceof CheckOnlyImpl) { syncHaveList(files, populate); } else { syncFiles(files, populate); } Seems it was designed to only check the latest revision and run a sync -k... /** * Test to see if workspace is at the latest revision. * * @ throws Exception */ private boolean syncHaveList(List<IFileSpec> files, Populate populate) throws Exception { // Preview (sync -k) SyncOptions syncOpts = new SyncOptions(); syncOpts.setClientBypass( true ); syncOpts.setQuiet(populate.isQuiet()); List<IFileSpec> syncMsg = iclient.sync(files, syncOpts); validateFileSpecs(syncMsg, "file(s) up-to-date." , "file does not exist" , "no file(s) as of that date" ); for (IFileSpec fileSpec : syncMsg) { if (fileSpec.getOpStatus() != FileSpecOpStatus.VALID) { String msg = fileSpec.getStatusMessage(); if (msg.contains( "file(s) up-to-date." )) { return true ; } } } return false ; }

          Michael Rose added a comment -

          I was attempting to use it in my workflow. The idea is that if this issue and JENKINS-30614 are addressed, then an inital sync could get the changelog and follow-up syncs could be used to download the source as needed.

          (workspaceA) Initial - Sync (CheckOnly) streamA [with changelog]
              (workspaceB) Debug Build - Sync streamA [nochangelog if JENKINS-30614]
              (workspaceC) Release Build - Sync streamA [nochangelog if JENKINS-30614]
          

          Michael Rose added a comment - I was attempting to use it in my workflow. The idea is that if this issue and JENKINS-30614 are addressed, then an inital sync could get the changelog and follow-up syncs could be used to download the source as needed. (workspaceA) Initial - Sync (CheckOnly) streamA [with changelog] (workspaceB) Debug Build - Sync streamA [nochangelog if JENKINS-30614] (workspaceC) Release Build - Sync streamA [nochangelog if JENKINS-30614]

          Michael Rose added a comment -

          I found a reasonable workaround. Instead of syncing the workspace N times, doing 1 sync, then a stash/unstash should works.

          Michael Rose added a comment - I found a reasonable workaround. Instead of syncing the workspace N times, doing 1 sync, then a stash/unstash should works.

          Karl Wirth added a comment -

          Closing due to lack of actvity. If this is still a problem in 1.9.5 please feel free to reopen this issue.

          Karl Wirth added a comment - Closing due to lack of actvity. If this is still a problem in 1.9.5 please feel free to reopen this issue.

            p4paul Paul Allen
            mrose Michael Rose
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: