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

[P4 Plugin] Shelve fails with 'tampered with after resolve' for utf8 files

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • p4-plugin
    • Jenkins LTS 2.121.1 on CentOS Linux release 7.3.1611 (Core)
      p4-plugin 1.8.15
      P4 Server version: P4D/LINUX26X86_64/2017.2/1622831 (2018/02/20)
      P4 Client on Windows 10

      Steps to reproduce:

      1. Create a new file with type <utf8>
      2. Branch that file
      3. Edit and submit changes to the original file
      4. Run a Jenkins pipeline job with steps similar to below:
      // helper method for creating a changelist
      def createChangelist(p4) {
      	def changelistId = -1
      	def changeForm = p4.fetch("change", "")
      	changeForm.put("Description", "Integrate")
      	def changeMsg = p4.save("change", changeForm)
      	def changeOutput = changeMsg[0].get("change")
      	if (changeOutput) {
      		def match = changeOutput =~ /Change (\d+)/
      		changelistId = match[0][1]
      	}
      	return changelistId
      }
      
      node {
      	// Define workspace
      	def view = "//depot/path/... //${P4_CLIENT}/depot/path..."
      	def spec = clientSpec(allwrite: false, backup: false, clobber: false, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, 
      		serverID: '', streamName: '', type: 'WRITABLE', view: view)
      	def ws = manualSpec(charset: 'none', name: 'jenkins-${JOB_NAME}', spec: spec)
      
      	// Create object
      	def p4 = p4(credential: 'phooey', workspace: ws)
      	def clientName = p4.getClientName()
      
      	def sourceFile = "//depot/path/file1.txt"
      	def targetFile = "//depot/path/file2.txt"
      
      	try {
      		def changelistId
      		stage("Integrate") {
      			changelistId = createChangelist(p4)
      			p4.run("integ", "-c${changelistId}", sourceFile, targetFile)
      		}
      		stage("Resolve") {
      			p4.run("resolve", "-as", "//${clientName}/...")
      		}
      		stage("Shelve") {
      			def shelveMsg = p4.run("shelve", "-c${changelistId}", "//${clientName}/...")
      			echo(shelveMsg.toString())
      		}
      	} catch (ex) {
      		echo(ex.getMessage())
      	} finally {
      		p4.run("revert", "-w", "//${clientName}/...")
      	}
      }
      

      The p4 shelve command will fail and return the following error message:

      %clientFile% tampered with after resolve - edit or revert.
      

      Note: I was unable to reproduce this error using only P4Java in a simple test program.

            p4paul Paul Allen
            stuartrowe Stuart Rowe
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: