You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins Windows入站代理Docker镜像中Redgate SQL工具安装失败求助

解决Windows Server Core容器中安装Redgate SQL Change Automation PowerShell工具的问题

针对基于jenkins/inbound-agent:jdk17-windowsservercore-ltsc2019镜像构建自定义镜像时遇到的安装失败问题,以下是针对性修复方案:

一、修复Chocolatey安装超时问题

Chocolatey安装超时多因容器网络或包下载速度受限,可通过延长超时时间、先升级Chocolatey解决:

# 先升级Chocolatey到最新版本
RUN choco upgrade chocolatey -y
# 延长超时时间至3600秒(1小时),指定仅安装SQL Change Automation PowerShell
RUN choco install sqltoolbelt -y --params "/products:'SQL Change Automation Powershell'" --timeout 3600

二、修复静默安装无文件生成问题

Windows Server Core容器环境下,静默安装需明确指定参数和安装路径,同时通过日志定位问题:

  1. 先创建临时目录存放安装包:
RUN mkdir C:\temp
  1. 下载SCAPowerShell安装包并执行带日志的静默安装:
RUN powershell -Command `
    Invoke-WebRequest -Uri "https://download.red-gate.com/installers/SQLChangeAutomationPowerShell/2024/SQLChangeAutomationPowerShell_2024.1.0.1234.exe" -OutFile "C:\temp\SCAPowerShell.exe"; `
    Start-Process -FilePath "C:\temp\SCAPowerShell.exe" -ArgumentList "/VERYSILENT /INSTALLDIR=`"C:\Program Files (x86)\Red Gate\SQL Change Automation PowerShell`" /LOG=`"C:\temp\sca_install.log`"" -Wait; `
    Remove-Item -Path "C:\temp\SCAPowerShell.exe" -Force
  1. 若安装后仍无文件,查看C:\temp\sca_install.log日志,排查依赖缺失或权限问题。

三、修复PowerShell 7模块安装后找不到的问题

Install-Module安装的模块存放在PowerShell模块路径中,而非C:\Program Files (x86)\Red Gate\目录,需按以下步骤操作:

  1. 安装模块前先信任PSGallery仓库:
RUN pwsh -Command `
    Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; `
    Install-Module SqlChangeAutomation -AcceptLicense -Force
  1. 验证安装:在容器中执行pwsh -Command Get-Module -ListAvailable SqlChangeAutomation,能输出模块信息则安装成功。
  2. 使用模块时直接在PowerShell 7中导入:Import-Module SqlChangeAutomation

四、容器环境额外注意事项

  • Windows Server Core无GUI环境,所有安装必须使用纯静默参数(如/VERYSILENT),禁止依赖交互界面的参数。
  • 确保容器内安装了.NET Framework 4.8(部分Redgate工具依赖):
RUN powershell -Command `
    Invoke-WebRequest -Uri "https://download.visualstudio.microsoft.com/download/pr/15852001/9a1d015f6e17d0928f85bceb3e14c38a/netfx48.exe" -OutFile "C:\temp\netfx48.exe"; `
    Start-Process -FilePath "C:\temp\netfx48.exe" -ArgumentList "/q /norestart" -Wait; `
    Remove-Item -Path "C:\temp\netfx48.exe" -Force
  • 检查Redgate默认日志:工具会在C:\ProgramData\Red Gate\Logs生成安装日志,可从中定位具体失败原因。

内容的提问来源于stack exchange,提问作者MayurSatpute

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 23:15:35