Jenkins+PowerShell持续集成环境搭建(五)SSRS项目
部署SSRS项目的原理是使用ReportingService2005类的方法实现rdl文件上传等功能。
上传rdl文件的脚本示例:
1 $username="Victor"; 2 $password="******"; 3 4 $pass = ConvertTo-SecureString -AsPlainText $password -Force 5 $credential= New-Object System.Management.Automation.PSCredential -ArgumentList $username,$pass 6 7 $uri="http://YourServer/ReportServer/ReportService2005.asmx"; 8 9 $webServiceProxy = New-WebServiceProxy -Uri $uri -Credential $credential 10 11 $rdlName="Test" 12 13 #Backup 14 $backupDateFormat = (Get-Date -format yyyy_MM_dd) 15 $backupDir= "D:\" + $backupDateFormat +"\Report\"+$rdlName 16 $rdlDefinitionBackup = $webServiceProxy.GetReportDefinition("Report/" + $rdlName) 17 $memoryStreamBackup = New-Object System.IO.MemoryStream (,$rdlDefinitionBackup) 18 $xmlDocBackup = New-Object "System.Xml.XmlDocument" 19 $xmlDocBackup.Load($memoryStreamBackup) 20 $xmlDocBackup.Save(backupDir+".rdl") 21 22 #Upload 23 $rdlDir="D:\CI\File\"+$rdlName+".rdl" 24 $rdlFileStream=[System.Io.File]::OpenRead($rdlDir) 25 $rdlFileStreamLength=$rdlFileStream.Length 26 $rdlDefinition = New-Object Byte[] $rdlFileStreamLength 27 $rdlFileStream.Read($rdlDefinition, 0, $rdlFileStreamLength); 28 $rdlFileStream.Close(); 29 $webServiceProxy.CreateReport($rdlName,"/Report",$TRUE,$rdlDefinition,$NULL)