如何在Cloudbees Pipeline中保存Docker卷以防失败

我在一个由Jenkins-Pipeline-Stage(Cloudbees-plugin)启动的Docker-Container中运行一组APItesting。

如果舞台(见下文)失败,我想保存testing日志。 我试图在后期采取后续操作,但之后我无法再访问该映像。 你将如何解决这个问题? 如何在失败的情况下保存图像?

stage('build Dockerimage and run API-tests') { steps{ script { def apitestimage = docker.build('apitestimage', '--no-cache=true dockerbuild') apitestimage.inside('-p 5800:5800') { dir('testing'){ sh 'ctest -V' } } sh 'docker rmi --force apitestimage' } } } 

使用post { failure { .. } }步骤将失败阶段的数据直接归档到失败阶段,而不是在以后。