安装包时 Jenkins 构建作业失败

Jenkins build job fails while installing a package

我正在开发一个 Jenkins 文件,它应该能够在部署前使用量角器执行 e2e 测试。所以我需要为 chrome-headless 安装安装几个包(是的,我已经检查了多个具有不同想法的页面来启动这个无头的东西,但没有一个对我有用,所以我最终还是在这里问题)。当我在 Jenkins 上开始构建时,我得到了这个输出:

[ature_ChromeHeadlessJenkins-
I3N4DKAF3MHS72RV35MYVEHTF7OCMJ2VQKG54JMW2L7IQHOYN66A] Running shell script
+ apt-get install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 
libxss1 fonts-liberation libappindicator1 xdg-utils
Reading package lists...
Building dependency tree...
Reading state information...
libgtk2.0-0 is already the newest version (2.24.31-2).
libgtk2.0-0 set to manually installed.
libxpm4 is already the newest version (1:3.5.12-1).
libxpm4 set to manually installed.
libxrender1 is already the newest version (1:0.9.10-1).
libxrender1 set to manually installed.
The following additional packages will be installed:
cpp cpp-6 gconf-service gconf2-common libauthen-sasl-perl libdbus-glib-1-2
libdbusmenu-glib4 libdbusmenu-gtk4 libencode-locale-perl
libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl
libfile-mimeinfo-perl libfont-afm-perl libhtml-form-perl libhtml-format-perl
libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl
libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl
libhttp-message-perl libhttp-negotiate-perl libindicator7 libio-html-perl
libio-socket-ssl-perl libipc-system-simple-perl libisl15
liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libmpc3
libmpfr4 libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl
libnet-ssleay-perl libtext-iconv-perl libtie-ixhash-perl libtimedate-perl
liburi-perl libwww-perl libwww-robotrules-perl libx11-protocol-perl
libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl
perl-openssl-defaults x11-xserver-utils
Suggested packages:
cpp-doc gcc-6-locales libdigest-hmac-perl libgssapi-perl libdata-dump-perl
libcrypt-ssleay-perl libauthen-ntlm-perl libunicode-map8-perl
libunicode-string-perl xml-twig-tools nickle cairo-5c xorg-docs-core
gvfs-bin
The following NEW packages will be installed:
cpp cpp-6 fonts-liberation gconf-service gconf2-common libappindicator1
libauthen-sasl-perl libdbus-glib-1-2 libdbusmenu-glib4 libdbusmenu-gtk4
libencode-locale-perl libfile-basedir-perl libfile-desktopentry-perl
libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libgconf-2-4
libhtml-form-perl libhtml-format-perl libhtml-parser-perl
libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
libhttp-negotiate-perl libindicator7 libio-html-perl libio-socket-ssl-perl
libipc-system-simple-perl libisl15 liblwp-mediatypes-perl
liblwp-protocol-https-perl libmailtools-perl libmpc3 libmpfr4
libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl
libtext-iconv-perl libtie-ixhash-perl libtimedate-perl liburi-perl
libwww-perl libwww-robotrules-perl libx11-protocol-perl libxml-parser-perl
libxml-twig-perl libxml-xpathengine-perl libxss1 perl-openssl-defaults
x11-xserver-utils xdg-utils
The following packages will be upgraded:
libnss3
1 upgraded, 55 newly installed, 0 to remove and 1 not upgraded.
Need to get 14.9 MB of archives.
After this operation, 45.3 MB of additional disk space will be used.

这不是错误,但由于某种原因脚本执行在此时停止。我认为这是因为 apt-get 或 dpkg 要我的同意才能安装。我试图强制安装,但没有成功。

这是我的 Jenkinsfile 的一部分:

sh 'webdriver-manager update'

sh 'apt-get update'
sh 'apt-get install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 '
sh 'apt-get install -f libxss1 fonts-liberation libappindicator1 xdg-utils' //FAILS HERE
sh 'wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'
sh 'dpkg -i --force-all google-chrome-stable_current_amd64.deb'
sh 'apt-get install -f'

sh 'apt-get install xvfb gtk2-engines-pixbuf'
sh 'apt-get install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable'
sh 'apt-get install imagemagick x11-apps dbus-x11'
sh 'Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99'
sh 'webdriver-manager start /dev/null 2>&1'

有人可以帮我解决这个问题吗?如果您需要更多信息,请询问。感谢

使用-y

发现 apt-get install -y [package] 正在解决我的问题。阅读手册页很有帮助我发现...