【问题标题】:How can I store SSRS reports in Git for use with Azure DevOps?如何在 Git 中存储 SSRS 报告以用于 Azure DevOps?
【发布时间】:2020-06-27 03:39:50
【问题描述】:

我的团队最近从 TFS/Team City 切换到 Git/Azure DevOps,我们希望将我们发布的报告包含在我们新的 CI/CD 管道中。

我们以前没有以这种方式整合我们的报告;我们的数据库项目中包含存储过程,但报表定义文件 (RDL) 是手动部署到报表服务器的。我已经找到了如何在 Azure DevOps 中构建管道,但我不确定我们如何将 RDL 迁移到 Github。是只是在其中创建一个新的解决方案那么简单,还是更复杂?

【问题讨论】:

  • 您的报表是否在 Visual Studio 报表项目中?如果是这样,这里有一个例子GitHub SSRS Example
  • 这是我们试图弄清楚如何组织项目的一部分。我们现在有两个想法:每个报告一个项目或所有报告一个项目。我喜欢组织它,以便报告按类型或用例分组到项目中。
  • 在我的公司,我们使用一个解决方案组织我们的报告,该解决方案按学科划分多个项目,例如人力资源、财务、信息技术等。然后我们为每个文件夹创建活动目录组以分配用户。
  • 另外,我建议使用数据库用户作为服务帐户来运行报告,因此用户需要的唯一权限是 AD 组。
  • 谢谢,这很有帮助。我们唯一的大问题是我们的一些报告是交叉使用的。我将建议我们为多用途报告构建一个“交叉”项目

标签: git github reporting-services continuous-integration


【解决方案1】:

我们所做的是将报告下载到 XML 文件中,然后将它们推送到 git 存储库中。

这会为目录中的每个报告创建很好的文件夹子集和 XML 文件

--select * from #ReportDetails
--drop table #ReportDetails
-- select * from #Temp
-- drop table #Temp

DECLARE @intFlag INT=1  /*To start with 1 in while loop*/
DECLARE @MaxReportCount INT

Select   ROW_NUMBER() over (order by ItemId) as Report_No,ItemId,Name as Report_name,[Path] as Report_Path,replace(SUBSTRING(PATH,1,LEN(PATH)-(LEN(Name)+1)),'/','\') as Folder_Path
       into #ReportDetails
       from [dbo].[Catalog]
       where [Type]=2 /*Load all the reports (Type=2 indicates) from catalog table to table variable*/
select @MaxReportCount = MAX(Report_No) from #ReportDetails /*Get max count to pass as highest value in while loop*/

-- options to download spacific reports or folders. 
--delete from #ReportDetails 
    --where Folder_Path <> '\C3 Reports'
    --where  Report_name <> 'Care Message Referrals and Diagnostics'

     Declare @FolderContainer AS NVARCHAR(200)
     declare @cmd as varchar(MAX) /*Hold xml file for report*/
     declare @Reportqueryout as varchar (240) /*Hold report output path*/
     declare @DynamicQuery AS NVARCHAR(MAX) /*Hold xp_cmdshell string for generating RDL file*/

WHILE (@intFlag <= @MaxReportCount)  /*Declare loop to generate rdl file of all reports one by one*/
BEGIN
    
     Select @FolderContainer='<add local folder here drive here>'+Folder_Path from #ReportDetails where Report_No=@intFlag

     Select @cmd =  CONVERT(VARCHAR(MAX),  
           CASE       
             WHEN LEFT(C.Content,3) = 0xEFBBBF THEN STUFF(C.Content,1,3,'''')        
             ELSE C.Content        END) 
     FROM  '<add report database here>'.[dbo].[Catalog] CL
       CROSS APPLY (SELECT CONVERT(VARBINARY(MAX),CL.Content) Content) C  WHERE  CL.ItemID =
               (Select ItemId from #ReportDetails
     where Report_No=@intFlag)

     select * into #Temp from (select @cmd temp) a /*store XML file to temp table*/
       ------------------------------------
      
        EXEC master.dbo.xp_create_subdir @FolderContainer
   
     --  ------------------------------------
        select @Reportqueryout= '"'+@FolderContainer+'\'+Report_name+'.rdl"'
     from #ReportDetails
     where  Report_No=@intFlag /*Generate output path */

     select @DynamicQuery='EXEC master..xp_cmdshell ''bcp " '
                           + 'Select Temp from #Temp" QUERYOUT '
                           + @Reportqueryout
                           + ' -c   -T''' /* Here Localhost\reportinstance  is the SQL server name with instance*/

     EXEC SP_EXECUTESQL @DynamicQuery
           
     Drop table #Temp
        set @FolderContainer=''
        set @cmd=''
        set @Reportqueryout=''
        set @DynamicQuery=''

     SET @intFlag = @intFlag + 1 /*By increasing this go to or fetch next report*/
      

END

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多