How to run build/deploy only on rdl files

arielman2304 676 Reputation points
2021-04-26T11:43:04.657+00:00

Hi
I'm running the below build command from CMD (runs on windows slave from jenkins):

    bat "devenv.com MyProject.sln /Build Release"

My output to bin\Release are *.rdl files + *.obj files + *.rds files

After that, I'm running the below deploy command:

 bat ' rs.exe -i pipeline\\ssrs\\Upload_Multiple_RDL_files.rss -s "{My report server}" -v FILE_NAME="pipeline\\ssrs\\ConfigurationFile.txt" '

and here I get error once it reached non rdl files:

The definition of this report is not valid or supported by this version of Reporting Services

Is there a way to avoid it? for example, run build and see only the *.rdl files in bin\Release or modify Upload_Multiple_RDL_files.rss VB script which I took from this answer to run only on *.rdl files?

Upload_Multiple_RDL_files.rss content:

'Script Starting Point
' Script to deploy report to report server
' EXECUTE VIA COMMAND LINE

DIM definition As [Byte]() = Nothing
DIM warnings As Warning() = Nothing

Public Sub Main()

' Variable Declaration
        Dim TextLine As String = ""
        Dim LocalDir As String = ""
        Dim ServerDir As String = ""
        Dim definition As [Byte]() = Nothing
        'Dim warnings As Warning() = Nothing

' Reading Configuration Text file and assigning the values to variables
        If System.IO.File.Exists(FILE_NAME) = True Then
            Dim objReader As New System.IO.StreamReader(FILE_NAME)
            Do While objReader.Peek() <> -1
                TextLine = objReader.ReadLine()
                Dim parts As String() = TextLine.Split(New Char() {","c})
                'TextLine & objReader.ReadLine() '& vbNewLine
                LocalDir = parts(0)
                ServerDir = parts(1)

                Dim path As String = LocalDir
                Dim fileEntries As String() = Directory.GetFiles(path)
                Dim fileFullPath As String = ""
                For Each fileFullPath In fileEntries


' Deploying the Reports
                    Try
                        Dim stream As FileStream = File.OpenRead(fileFullPath)
                        Dim NameWithExt As String = fileFullPath.Replace(path, "")
                        Dim NameOnly As String = NameWithExt.Replace(".rdl", "")
                        definition = New [Byte](stream.Length-1) {}
                        stream.Read(definition, 0, CInt(stream.Length))

      warnings = rs.CreateReport(NameOnly, ServerDir, True, definition, Nothing)

      If Not (warnings Is Nothing) Then
        DIM warning As Warning
        For Each warning In warnings
        Console.WriteLine(warning.Message)
        Next warning
      Else
       Console.WriteLine("Report: {0} PUBLISHED!", NameOnly)
      End If

     Catch e As IOException
      Console.WriteLine(e.Message)
     End Try
    Next fileFullPath
   Loop
         Else

            Dim MsgBox as String = "File Does Not Exist"

        End If
End Sub

'End of the Script
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,102 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
1,829 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. arielman2304 676 Reputation points
    2021-04-26T18:25:49.793+00:00

    I'm not VB expert, but the below worked for me:

    'Script Starting Point
    ' Script to deploy report to report server
    ' EXECUTE VIA COMMAND LINE
    
    DIM definition As [Byte]() = Nothing
    DIM warnings As Warning() = Nothing
    
    Public Sub Main()
    
    ' Variable Declaration
            Dim TextLine As String = ""
            Dim LocalDir As String = ""
            Dim ServerDir As String = ""
            Dim definition As [Byte]() = Nothing
            'Dim warnings As Warning() = Nothing
    
    ' Reading Configuration Text file and assigning the values to variables
            If System.IO.File.Exists(FILE_NAME) = True Then
                Dim objReader As New System.IO.StreamReader(FILE_NAME)
                Do While objReader.Peek() <> -1
                    TextLine = objReader.ReadLine()
                    Dim parts As String() = TextLine.Split(New Char() {","c})
                    'TextLine & objReader.ReadLine() '& vbNewLine
                    LocalDir = parts(0)
                    ServerDir = parts(1)
    
                    Dim path As String = LocalDir
                    Dim fileEntries As String() = Directory.GetFiles(path)
                    Dim fileFullPath As String = ""
                    For Each fileFullPath In fileEntries
    
    
    ' Deploying the Reports
                        Try
                            Dim stream As FileStream = File.OpenRead(fileFullPath)
                            Dim NameWithExt As String = fileFullPath.Replace(path, "")
                            Dim NameOnly As String = NameWithExt.Replace(".rdl", "")
                            definition = New [Byte](stream.Length-1) {}
                            stream.Read(definition, 0, CInt(stream.Length))
    
                            If NameWithExt Like "*rdl*" Then
                                warnings = rs.CreateReport(NameOnly, ServerDir, True, definition, Nothing)
                                Console.WriteLine("Report: {0} PUBLISHED!", NameOnly)
                            End If
    
                        Catch e As IOException
                            Console.WriteLine(e.Message)
                        End Try
                    Next fileFullPath
                    Loop
            Else
                Dim MsgBox as String = "File Does Not Exist"
            End If
    End Sub
    
    'End of the Script
    
    No comments