У меня есть задача pw sh, которая выполняет apt install
как часть psake exec
. apt install
, похоже, выдает предупреждение, которое превращает его в выходной поток конвейера, независимо от того, как я пытаюсь его перехватить:
"ПРЕДУПРЕЖДЕНИЕ: apt не имеет стабильного интерфейса CLI. Используйте с осторожностью в сценариях"
##[debug]Processed: ##vso[task.issue type=error;]%0AWARNING: apt does not have a stable CLI interface. Use with caution in scripts.%0A%0A
Я завернул его в try-catch, установил exit 0
, но ничего не помогло. Что я делаю не так, еще не подумал, или это еще одна проблема, о которой я пока не знаю?
Примечание. ошибки, но явно не предупреждение, особенно для кода, который успешно выполняется.
PowerShell
if ($IsLinux) {
Exec {
try {
Write-Host 'Executing apt install on Linux...'
sudo apt install nuget
Exit 0
} catch {
Exit 0
}
}
}...
Конвейерная задача
steps:
- pwsh: |
if ($null -eq (Get-Module -Name psake -listAvailable)) {
Install-Module psake -AcceptLicense -Force
}
Import-Module psake
Invoke-psake ./build/tasks.ps1 -taskList Test
exit ([int](-not $psake.build_success))
displayName: Execute Unit Tests and Build Package
failOnStderr: true
name: Build_and_Test
Соответствующий вывод журнала
Executing Init
Installing package 'PSDepend' Downloaded 0.00 MB out of 0.07 MB. [ ] Installing package 'PSDepend' Unzipping [ooooooooooooooooooooooooooooooooooooooooooooooo ] Installing package 'BuildHelpers' Downloaded 0.00 MB out of 0.08 MB. [ ] Installing package 'Pester' Downloaded 0.00 MB out of 0.85 MB. [ ] Installing package 'Pester' Downloaded 0.09 MB out of 0.85 MB. [oooo ] Executing Clean
Executing Build
Directory: /home/vsts/work/1/s
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 3/6/20 3:39 PM dist
Checking for NuGet install...
NuGet not installed, installing...
Executing apt install on Linux...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
bc dns-root-data dnsmasq-base ebtables grub-pc-bin landscape-common
liblldb-6.0 liblldb-8 liblxc-common liblxc1 libuv1 linux-headers-4.15.0-88
lxcfs lxd lxd-client python3-attr python3-automat python3-click
python3-colorama python3-constantly python3-hyperlink python3-incremental
python3-pam python3-pyasn1 python3-pyasn1-modules python3-service-identity
python3-twisted python3-twisted-bin python3-zope.interface uidmap xdelta3
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
nuget
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 1307 kB of archives.
After this operation, 5826 kB of additional disk space will be used.
Get:1 https://download.mono-project.com/repo/ubuntu stable-bionic/main amd64 nuget all 5.5.0.6319.bin-0xamarin1+ubuntu1804b1 [1307 kB]
Fetched 1307 kB in 0s (12.1 MB/s)
Selecting previously unselected package nuget.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 267481 files and directories currently installed.)
Preparing to unpack .../nuget_5.5.0.6319.bin-0xamarin1+ubuntu1804b1_all.deb ...
Unpacking nuget (5.5.0.6319.bin-0xamarin1+ubuntu1804b1) ...
Setting up nuget (5.5.0.6319.bin-0xamarin1+ubuntu1804b1) ...
##[debug]Exit code 0 received from tool '/usr/bin/pwsh'
##[debug]STDIO streams have closed for tool '/usr/bin/pwsh'
##[debug]task result: Failed
##[error]PowerShell wrote one or more lines to the standard error stream.
##[debug]Processed: ##vso[task.issue type=error;]PowerShell wrote one or more lines to the standard error stream.
##[debug]Processed: ##vso[task.complete result=Failed;]PowerShell wrote one or more lines to the standard error stream.
##[error]
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
##[debug]Processed: ##vso[task.issue type=error;]%0AWARNING: apt does not have a stable CLI interface. Use with caution in scripts.%0A%0A
Finishing: Execute Unit Tests and Build Package