Skip to content

Commit

Permalink
[JENKINS-44738] Use FileSystemObject.CopyFile() to copy instead of ca…
Browse files Browse the repository at this point in the history
…lling cmd.exe. Add suffix to backup file not to overwrite an existing one. Make installation not fail because a failure during the backup.
  • Loading branch information
Evaristo Gutiérrez committed Jun 13, 2017
1 parent 934d66d commit 8e681e2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions msi/jenkins.wxs
Expand Up @@ -46,16 +46,29 @@

<CustomAction Id="BackupJenkinsXmlFile" Script="vbscript">
<![CDATA[
On Error Resume Next
Err.Clear
jenkinsDirPath = session.Property("JENKINSDIR")
Set fsObj = CreateObject("Scripting.FileSystemObject")
If fsObj.FolderExists(jenkinsDirPath) Then
jenkinsXmlPath = jenkinsDirPath + "jenkins.xml"
srcPath = jenkinsDirPath & "jenkins.xml"
If fsObj.FileExists(jenkinsXmlPath) Then
Set shellObj = CreateObject("WScript.Shell")
cmdToExecute = "cmd.exe /C copy """ + jenkinsXmlPath + """ """ + jenkinsXmlPath + ".backup"" /Y"
shellObj.run(cmdToExecute)
If fsObj.FileExists(srcPath) Then
dstPath = jenkinsDirPath & "jenkins.xml.backup"
If fsObj.FileExists(dstPath) Then
suffix = 1
While fsObj.FileExists(dstPath & "_" & suffix)
suffix = suffix + 1
Wend
dstPath = dstPath & "_" & suffix
End If
fsObj.CopyFile srcPath, dstPath, True
Err.Clear
On Error Goto 0
End If
End If
]]>
Expand Down

0 comments on commit 8e681e2

Please sign in to comment.