[JIRA] (JENKINS-53588) [P4 Plugin] Shelve fails with 'tampered with after resolve' for utf8 files

216 views
Skip to first unread message

stuartr@ea.com (JIRA)

unread,
Sep 14, 2018, 4:30:03 PM9/14/18
to jenkinsc...@googlegroups.com
Stuart Rowe created an issue
 
Jenkins / Bug JENKINS-53588
[P4 Plugin] Shelve fails with 'tampered with after resolve' for utf8 files
Issue Type: Bug Bug
Assignee: Unassigned
Components: p4-plugin
Created: 2018-09-14 20:29
Environment: 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
Labels: p4-plugin
Priority: Major Major
Reporter: Stuart Rowe

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

stuartr@ea.com (JIRA)

unread,
Sep 14, 2018, 6:30:04 PM9/14/18
to jenkinsc...@googlegroups.com

pallen@perforce.com (JIRA)

unread,
Sep 17, 2018, 6:58:02 AM9/17/18
to jenkinsc...@googlegroups.com
Paul Allen commented on Bug JENKINS-53588
 
Re: [P4 Plugin] Shelve fails with 'tampered with after resolve' for utf8 files

Does your file include a UTF8 BOM? Java may write the BOM, there might be a config option in p4java to change behaviour.

pallen@perforce.com (JIRA)

unread,
Sep 17, 2018, 6:59:01 AM9/17/18
to jenkinsc...@googlegroups.com

stuartr@ea.com (JIRA)

unread,
Sep 17, 2018, 10:40:03 PM9/17/18
to jenkinsc...@googlegroups.com
Stuart Rowe commented on Bug JENKINS-53588
 
Re: [P4 Plugin] Shelve fails with 'tampered with after resolve' for utf8 files

Paul Allen The Jenkins node has JVM option -Dcom.perforce.p4java.filesys.utf8bom=0 to prevent writing the BOM. However, I added an input step in between the resolve and shelve stages and noticed that the target file does have a BOM after the resolve which is unexpected.

pallen@perforce.com (JIRA)

unread,
Sep 18, 2018, 4:23:06 AM9/18/18
to jenkinsc...@googlegroups.com

I'll raise a P4Java bug on resolve; good timing as we are planning to overhaul P4Java before the end off the year.

kwirth@perforce.com (JIRA)

unread,
Sep 25, 2018, 7:23:02 AM9/25/18
to jenkinsc...@googlegroups.com

Confirm that this is a P4JAVA bug. The BOM is added even if  '-Dcom.perforce.p4java.filesys.utf8bom=0 ' is set in the environment. I cannot reproduce the tamper error yest but it doesn't matter because the file is corrupt and I can see the MD5SUM no longer matches.

Source:

$ od -a test.txt 
0000000   H   e   l   l   o  sp   W   o   r   l   d
0000013

Target:

$ od -a test.txt 
0000000   o   ;   ?   H   e   l   l   o  sp   W   o   r   l   d
0000016

Setup test in P4 ("p4 integ //depot/src/test2.txt //depot/src/test.txt").

Very simple resolve code used:

System.out.println("Run ExecMap Command");
String[] execMapArgs = {"-as","//depot/src/test.txt"};
List<Map<String, Object>> resultMaps = server.execMapCmdList("resolve",execMapArgs, null);
System.out.println("\nCommand Output:");
for ( Map myMap: resultMaps) {for (Object value: myMap.values()) {System.out.print(value);}}

 

 

kwirth@perforce.com (JIRA)

unread,
Sep 25, 2018, 7:24:02 AM9/25/18
to jenkinsc...@googlegroups.com

pallen@perforce.com (JIRA)

unread,
Sep 27, 2018, 10:03:02 AM9/27/18
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages