Steps to reproduce:
- Create a new file with type <utf8>
- Branch that file
- Edit and submit changes to the original file
- 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.
Does your file include a UTF8 BOM? Java may write the BOM, there might be a config option in p4java to change behaviour.