我正试图通过Jenkins管道构建一个docker映像,这需要很长的时间(4-5个小时,大多数时候都失败了(。当我从同一台詹金斯机器的命令行构建图像时,大约需要20分钟。这些是Dockerfile命令,作业在该命令下停止-
ARG PKGS="askpass, assertthat, backports, base64enc, BH, bit, bit64, blob, brew, brio, broom, callr, caret, cellranger, chron, cli, clipr, colorspace, commonmark, config, covr, cpp11, crayon, credentials, crosstalk, curl, data.table, DBI, dbplyr, desc, devtools, diffobj, digest, dplyr, DT, ellipsis, evaluate, fansi, farver, fastmap, forcats, foreach, forge, fs, future, generics, gert, ggplot2, gh, gitcreds, glmnet, globals, glue, gower, gridExtra, gsubfn, gtable, haven, highr, hms, htmlwidgets, httpuv, httr, ini, ipred, isoband, iterators, jsonlite, knitr, labeling, later, lava, lazyeval, lifecycle, listenv, lubridate, magrittr, markdown, memoise, mime, ModelMetrics, modelr, munsell, numDeriv, openssl, parallelly, pillar, pkgbuild, pkgconfig, pkgload, plogr, plyr, praise, prettyunits, pROC, processx, prodlim, progress, promises, proto, ps, purrr, r2d3, R6, randomForest, rappdirs, rcmdcheck, RColorBrewer, Rcpp, readxl"
# Install through pak and other cleanup tasks
RUN Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")'
&& echo "$PKGS"
| Rscript -e 'pak::pkg_install(strsplit(readLines("stdin"), ", ?")[[1L]], ask = FALSE)'
&& Rscript -e 'pak::cache_clean()'
ARG PKGS="recipes, rematch, rematch2, remotes, reprex, reshape2, rex, rlang, rmarkdown, roxygen2, rprojroot, RSQLite, rstudioapi, rversions, rvest, scales, selectr, sessioninfo, shape, shiny, sourcetools, sparklyr, SparkR, sqldf, SQUAREM, stringi, stringr, sys, testthat, tibble, tidyr, tidyselect, tidyverse, timeDate, tinytex, usethis, utf8, uuid, vctrs, viridisLite, waldo, whisker, withr, xfun, xml2, xopen, xtable, yaml, zip"
# Install through pak and other cleanup tasks
RUN Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")'
&& echo "$PKGS"
| Rscript -e 'pak::pkg_install(strsplit(readLines("stdin"), ", ?")[[1L]], ask = FALSE)'
&& Rscript -e 'pak::cache_clean()'
我怀疑这与Jenkins有关,因为构建从命令行进行得很好。詹金斯是否有一些设置减缓了这些软件包的下载和安装速度?非常感谢。
弄清楚了这一点,需要用前面的\转义$字符,这样它就不会被求值。基本上将"$PKGS"
替换为"\$PKGS"
。