Skip to content
Permalink
Browse files

[JENKINS-44738] Use FileSystemObject.CopyFile() to copy instead of ca…

…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
varyvol committed Jun 13, 2017
1 parent 934d66d commit 8e681e21175fa0ea7e05691c759384097b15a060
Showing with 18 additions and 5 deletions.
  1. +18 −5 msi/jenkins.wxs
@@ -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
]]>

0 comments on commit 8e681e2

Please sign in to comment.
You can’t perform that action at this time.