由Octopus发布SSRS

时间:2015-11-27 04:28:23

标签: powershell reporting-services sql-server-2012 octopus-deploy

我正在构建通过Octopus Deploy部署我的SSRS报告的设置,我发现了一个Octopus Library并且我正在研究它,但我遇到了一些问题:

1º----消息错误:(路径正常,但它保持相同的警告) 警告:无法在/ Sales Drivers / Data Sources

中找到数据源SalesDrivers

2º----该方法不存在 方法调用失败,因为[Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3er_ReportService2005_asmx_wsdl.ReportingService2005]不包含名为“LoadReportDefinition”的方法。

出现错误的模板\库中的powershell函数可以在下面看到:

#region Update-ReportParamters()
Function Update-ReportParameters($ReportFile)
{
    # declare local variables
    $ReportParameters = @();

    # necessary so that when attempting to use the report execution service, it doesn't puke on you when it can't find the data source
    $ReportData = (Remove-SharedReferences -ReportFile $ReportFile)

    # get just the report name
    $ReportName = $ReportFile.SubString($ReportFile.LastIndexOf("\") + 1)
    $ReportName = $ReportName.SubString(0, $ReportName.IndexOf("."))

    # create warnings object
    $ReportExecutionWarnings = $null

    # load the report definition
    Write-Host "*********************************************"

    #Write-Host $ReportData
    #(Remove-SharedReferences -ReportFile $ReportFile)

    #Write-Host $ReportExecutionWarnings

    $ExecutionInfo = $ReportExecutionProxy.LoadReportDefinition($ReportData, [ref] $ReportExecutionWarnings);

    # loop through the report execution parameters
    foreach($Parameter in $ExecutionInfo.Parameters)
    {
        # create new item parameter object
        $ItemParameter = New-Object "$ReportServerProxyNamespace.ItemParameter";

        # fill in the properties except valid values, that one needs special processing
        Copy-ObjectProperties -SourceObject $Parameter -TargetObject $ItemParameter;

        # fill in the valid values
        $ItemParameter.ValidValues = Convert-ValidValues -SourceValidValues $Parameter.ValidValues;

        # add to list
        $ReportParameters += $ItemParameter;
    }

    # force the parameters to update
    Write-Host "Updating report parameters for $ReportFolder/$ReportName"
    if ($IsReportService2005) {
        $ReportServerProxy.SetReportParameters("$ReportFolder/$ReportName", $ReportParameters);
    }
    elseif ($IsReportService2010) {
        $ReportServerProxy.SetItemParameters("$ReportFolder/$ReportName", $ReportParameters);
    }
    else { Write-Warning 'Report Service Unknown in Update-ReportParameters method. Use ReportService2005 or ReportService2010.' }
}   

任何人都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我已经解决了类似的问题,但采取了稍微不同的方法。我没有直接使用PowerShell和章鱼,而是使用了有用的开源工具RSBuild来部署报告。很容易将rsbuild.exe可执行文件(它很小)和deploy.config与章鱼包内的报告捆绑在一起。然后你可以使用章鱼的替换功能重写配置文件和Powershell函数来执行可执行文件。这也有一个优点,你可以轻松部署而不用章鱼,数据源和报告的配置是用XML声明的,而不是Powershell中的程序,你的脚本部署的智能可以与你的报告一起存在,而不是埋在Octopus中。

所以我的配置看起来有点像:

<?xml version="1.0" encoding="utf-8" ?>
<Settings>
    <Globals>
        <Global Name="CollapsedHeight">0.5in</Global>
    </Globals>
    <ReportServers>
        <ReportServer Name="RS1" Protocol="http" Host="${ReportServer}" Path="${ReportServerPath}" Timeout="30" />
    </ReportServers>
    <DataSources>
        <DataSource Name="Source1" Publish="true" Overwrite="true" TargetFolder="Data Sources" ReportServer="RS1">
            <ConnectionString>data source=${ReportServer};initial catalog=${DatabaseName}</ConnectionString>
            <CredentialRetrieval>Store</CredentialRetrieval>
            <WindowsCredentials>False</WindowsCredentials>
            <UserName>${RepotrUser}</UserName>
            <Password>${ReportsPassword}</Password>
        </DataSource>
    </DataSources>
    <Reports>
        <ReportGroup Name="Details" DataSourceName="Source1" TargetFolder="Reports"
            ReportServer="RS1" CacheTime="10080">
            <Report Name="BusinessReportABC">
                <FilePath>reports\BusinessReportABC.rdl</FilePath>
            </Report>
            <!--More reports here-->
        </ReportGroup>
    </Reports>
</Settings>

我部署的octopacked文物包含RSBuild.Core.dll,RSBuild.exe,deploy.config和报告文件

然后我只使用powershell调用可执行文件:

PS> rsbuild deploy.config