Jenkins管道正在构建Docker镜像。OpenShift插件也同样使用。
命令示例:
openshift.selector(BUILD_CONFIG_NAME, "${appBcName}").startBuild("--from-dir=${artifactPath}", '--wait','--follow')
虽然这在大多数情况下工作顺利,但每当这个命令由于一些底层平台问题而失败时,在Jenkins构建作业控制台几乎看不到任何信息:
[Pipeline] }
[start-build:buildconfig/amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd] ............................................................
[start-build:buildconfig/amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd] Uploading finished
[start-build:buildconfig/amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd] Error from server (BadRequest): unable to wait for build amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd-857 to run: timed out waiting for the condition
[Pipeline] }
ERROR: Error running start-build on at least one item: [buildconfig/amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd];
{err=, verb=start-build, cmd=oc --server=https://api.scp-west-zone02-z01.net:6443 --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt --namespace=sb-1166-amld5-car-service-se --token=XXXXX start-build buildconfig/amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd --from-dir=./build/libs --wait --follow -o=name , out=Uploading directory "build/libs" as binary input for the build ...
............................................................
Uploading finished
Error from server (BadRequest): unable to wait for build amld5-car-reporting-spacetime-ubi-openshift-java-runtimejd-857 to run: timed out waiting for the condition
, status=1}
[Pipeline] // catchError
我需要更详细的错误信息。我检查了start-build命令参考,我认为--build-loglevel [0-5]
可能会有所帮助。当我使用它时,我得到了一个警告,因为我在BuildConfig中使用源类型为"二进制",所以不支持日志记录(真的吗??)注意:当给startBuild()提供-F/——follow时返回的选择器将对各种选择器操作不起作用。考虑从startBuild中删除这些选项,并使用logs()命令跟踪构建输出。
[start-build:buildconfig/casc-docs-spacetime-ubi-openshift-java-runtimeadoptopenjdk] WARNING: Specifying --build-loglevel with binary builds is not supported.
[start-build:buildconfig/casc-docs-spacetime-ubi-openshift-java-runtimeadoptopenjdk] WARNING: Specifying environment variables with binary builds is not supported.
[start-build:buildconfig/casc-docs-spacetime-ubi-openshift-java-runtimeadoptopenjdk] Uploading directory "build/libs" as binary input for the build ...
[start-build:buildconfig/casc-docs-spacetime-ubi-openshift-java-runtimeadoptopenjdk] ..
如何获得更多的日志,信息。在执行start-build命令时?
我也面临着同样的问题,我只是使用了这样的东西:
def build = openshift.selector(BUILD_CONFIG_NAME, "${appBcName}").startBuild("--from-dir=${artifactPath}", '--wait','--follow')
build.logs('-f')
到目前为止,它似乎工作,我从我的openshift构建在我的Jenkins管道的日志。现在,我将尝试仅在构建未完成时获取日志,以减少总体日志。
(对于像我这样的未来搜索者^^)
您可以转到openshift控制台并从那里检查日志。但我认为这个问题经常发生,如果你的openshift项目是缺乏分配的资源,无论是CPU或RAM。把它增加,问题可能就解决了