如何在 windows slave 的 groovy 文件中 运行 long msbuild 命令

How to run long msbuild command in groovy file in windows slave

我有以下 msbuild 本地部署命令:

msbuild "Database Services\Database Services.sqlproj" /t:deploy /p:TargetConnectionString="Data Source=TEST,111;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False" /p:BlockOnPossibleDataLoss=False /p:TargetDatabase="test_db"

在 jenkisfile.groovy 中 运行 的正确语法是什么? 我 运行ning 反对我的 windows 机器,所以我想它应该以 bat "msbuild ......."

开头

我尝试了很多语法,但都失败了

bat ' msbuild "Database Services\Database Services.sqlproj" /t:deploy /p:TargetConnectionString="Data Source=TEST,111;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False" /p:BlockOnPossibleDataLoss=False /p:TargetDatabase="test_db" '

那我建议多线,有更多的灵活性和自由度

bat (
    label: 'Run Tests',
    script: """
        set ASPNETCORE_ENVIRONMENT=Pipeline
        dotnet test
        if errorlevel 1 exit /b 1
    """
)

请注意,对于多行,您必须跟踪每一行的退出代码,因此虽然此处没有必要,但您可以以此拆分其他行,以确保构建在第一次失败时停止。