Redgate SQL Toolbelt components are not installing in Jenkins inbound-agent windows docker image

353 views Asked by At

I am trying to create a custom Docker image using jenkins/inbound-agent:jdk17-windowsservercore-ltsc2019 image. In this custom image, I want to install Redgate SQL Change Automation Powershell tool.

I tried all different ways of installing it, however, this doesn't seems to install at all.

The different ways I tried are:

  1. Using chocolatey RUN choco install sqltoolbelt -y --params "/products:'SQL Change Automation Powershell'") - This step just times out after running for a long time

  2. Downloaded the SCAPowershell exe and tried to install it: ENV SCA_URI=https://download.redgate.com/checkforupdates/SCAPowerShell/SCAPowerShell_4.5.22306.32404.exe RUN Invoke-WebRequest -Uri $env:SCA_URI -OutFile C:\SCAPowerShell_4.5.22306.32404.exe; \
    Start-Process -FilePath C:\SCAPowerShell_4.5.22306.32404.exe -ArgumentList "--quiet", "--wait", "/IAgreeToTheEula"
    - This step doesn't throw any error, but the component is never installed inside C:\Program Files (x86)\Red Gate\ directory where it's supposed to install

  3. Downloaded the SQL Toolbelt exe and tried to install it. This step also doesn't throw any error, but the component is never installed inside C:\Program Files (x86)\Red Gate\ directory where it's supposed to install

  4. Installed powershell 7 and tried to install the SQL Change Automation module using: RUN Install-Module SqlChangeAutomation -AcceptLicense -force

    This also doesn't install the component inside C:\Program Files (x86)\Red Gate directory where it's supposed to install

Please could someone help me so that I can try to get this installed in my docker image.

I'm already installing some of the prerequisites before installing this Regdate SQL Change Automation tool, like VS Tools, SSMS, SQLLocalDB, VS Community, but it still doesn't install.

Thank you

1

There are 1 answers

0
MayurSatpute On

I got it working after putting below in my Dockerfile. Here's my Dockerfile

FROM jenkins/inbound-agent:jdk17-windowsservercore-ltsc2019

SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]

RUN ["powershell","Set-ExecutionPolicy Bypass -Scope Process -Force;","iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"]

# Install VS Tools
RUN Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_buildtools.exe -OutFile C:\vs_buildtools.exe; \
Start-Process -FilePath C:\vs_buildtools.exe -ArgumentList "install", "--installPath", "C:/BuildTools", "--quiet", "--wait", "--add", "Microsoft.VisualStudio.Workload.VCTools", "--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" -Wait -PassThru

# Install 7Zip
RUN choco install 7zip.install -y

# Install SQL Server 2019
ADD https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLServer2019-x64-ENU-Dev.iso C:\\Users\\jenkins\\SQLServer2019-x64-ENU-Dev.iso
RUN 7z.exe x -y -oC:\\Users\\jenkins\\sqlserversetup C:\\Users\\jenkins\\SQLServer2019-x64-ENU-Dev.iso; \
powershell -Command Remove-Item C:\\Users\\jenkins\\SQLServer2019-x64-ENU-Dev.iso; \
C:\\Users\\jenkins\\sqlserversetup\\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS

# Install Net Framerwork 4.7
RUN choco install -y netfx-4.7-devpack

# Install VS Community
RUN Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_Community.exe -OutFile C:\vs_Community.exe; \
Start-Process -FilePath C:\vs_Community.exe -ArgumentList "install", "--installPath", "C:/VS", "--quiet", "--wait", "--norestart", "--add", "Microsoft.VisualStudio.Workload.CoreEditor", "--add", "Microsoft.VisualStudio.Workload.Data" -Wait -PassThru

# Check installation done or not
RUN dir C:/VS
RUN dir C:/BuildTools

# Install MS ODBC Driver for SQL Server
RUN Invoke-WebRequest -Uri https://download.microsoft.com/download/D/5/E/D5EEF288-A277-45C8-855B-8E2CB7E25B96/x64/msodbcsql.msi -OutFile C:\msodbcsql.msi; \
Start-Process msiexec.exe -Wait -ArgumentList '/I C:\msodbcsql.msi /quiet'

# Install MS Command Line Utilities
RUN Invoke-WebRequest -Uri https://download.microsoft.com/download/C/8/8/C88C2E51-8D23-4301-9F4B-64C8E2F163C5/x64/MsSqlCmdLnUtils.msi -OutFile C:\MsSqlCmdLnUtils.msi; \
Start-Process msiexec.exe -Wait -ArgumentList '/I C:\MsSqlCmdLnUtils.msi /quiet'


#Install SSMS
RUN choco install sql-server-management-studio -y

# Install SQL Change Automation
#RUN choco install sqltoolbelt -y --params "/products:'SQL Change Automation, SQL Change Automation Powershell'"
#RUN Install-PackageProvider NuGet -Force; Install-Module PowerShellGet -MinimumVersion 1.6 -Force -AllowClobber
#RUN Install-Module SqlChangeAutomation -Scope CurrentUser -AcceptLicense
RUN Get-PackageProvider NuGet -ForceBootstrap | Out-Null; Import-PackageProvider PowerShellGet; \
Install-Module -Name PowerShellGet -RequiredVersion 2.2.5 -Force; \
Invoke-Command { & "powershell.exe" } -NoNewScope
RUN Install-Module -Name SqlChangeAutomation -Force -AcceptLicense -ErrorAction Stop
RUN Invoke-Command { & "powershell.exe" } -NoNewScope
#RUN Invoke-DatabaseBuild

# Install pwsh
RUN choco install pwsh -y

SHELL ["pwsh", "-Command"]
# Set environment variable for MSBuild
RUN setx /M PATH $($Env:PATH+';C:/BuildTools/MSBuild/Current/bin/;')

# Install aws cli
RUN choco install awscli -y

#Install SQLLocalDB
RUN choco install sqllocaldb -y