docker-workflow插件在停止容器时,默认使用了参数 `--time=1`

通过如下 jenkinsfile ,使用给定的容器来执行 Pipeline 或 stage。

需安装 docker-workflow 插件。
https://plugins.jenkins.io/docker-workflow/

pipeline {

    agent {
        docker {
            image 'maven:3.9.3-eclipse-temurin-17'
            label 'my-defined-label'
            args  '-v /tmp:/tmp'
        }
    }
    
    stages {
        stage("run in docker") {
            steps {
                script {
                    try{
                        echo "============"
                    } catch (Exception e) {
                        echo "An error occurred: ${e.message}"
                    }
                }
            }
        }
    }

    post {
        failure {
            sh 'echo failure'
        }
        success {
            sh 'echo success'
        }
        aborted {
            sh 'echo aborted'
        }
    }
}

如日志所示,在流水线结束,清理容器时,默认使用了参数 --time=1

image.png

https://issues.jenkins.io/browse/JENKINS-66595

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容