Jenkins工作区中的@tmp文件夹是什么以及如何清理它们 [英] What are the @tmp folders in a Jenkins workspace and how to clean them up

查看:1274
本文介绍了Jenkins工作区中的@tmp文件夹是什么以及如何清理它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jenkins管道,用于Docker容器中的PHP项目。这是我的Jenkinsfile:

I have a Jenkins pipeline, for a PHP project in a Docker container. This is my Jenkinsfile:

pipeline {
  agent any
  stages {
    stage('Build') {
      agent any
      steps {
        sh 'docker-compose up -d'
        sh 'docker exec symfony composer install'
      }
    }
    stage('Test') {
      steps {
        sh 'docker exec symfony php ./bin/phpunit --coverage-clover=\'reports/coverage/coverage.xml\' --coverage-html=\'reports/coverage\' --coverage-crap4j=\'reports/crap4j.xml\''
      }
    }
    stage('Coverage') {
      steps {
        step([$class: 'CloverPublisher', cloverReportDir: '/reports/coverage', cloverReportFileName: 'coverage.xml'])
      }
    }
  }  
  post {
    cleanup {
      sh 'docker-compose down -v'
      cleanWs()
    }
  }
}

在运行管道之后, var / lib / jenkins / workspace 文件夹包含4个文件夹( umum我的项目名称是 Foo ):

After running the pipeline, the var/lib/jenkins/workspace folder contains 4 folders (assuming my project name is Foo):


  1. Foo

  2. Foo @ 2

  3. Foo @ 2 @ tmp

  4. Foo @ tmp

  1. Foo
  2. Foo@2
  3. Foo@2@tmp
  4. Foo@tmp

这些是什么,我该如何清理它们? cleanWs 不会删除除构建后的第一个以外的任何东西。

What are these, and how do I clean them up? cleanWs does not remove any except the first of them after the build.

编辑:这不是对这个问题,因为


  • 该问题不能回答我的问题:这些文件是什么。

  • 该问题的答案建议使用 deleteDir ,当使用Docker容器时,不推荐

  • That question does not answer my question: what are these files.
  • The answers to that question suggest using deleteDir, which is not recommended when using Docker containers.

推荐答案

有一个打开的 Jenkins问题,关于deleteDir()不删除@ tmp / @ script / @ ...目录。

There is an opened Jenkins issue about deleteDir() not deleting the @tmp/@script/@... directories.

删除这些内容的解决方法:

A workaround to delete those:

post {
  always {
    cleanWs()
    dir("${env.WORKSPACE}@tmp") {
      deleteDir()
    }
    dir("${env.WORKSPACE}@script") {
      deleteDir()
    }
    dir("${env.WORKSPACE}@script@tmp") {
      deleteDir()
    }
  }
}

还有一个评论关于描述 @tmp 是什么的问题:

There is also a comment on the issue describing what @tmp is:


它[@tmp文件夹]包含在
运行时加载的任何库的内容。没有副本,重播就无法可靠地工作。

It [@tmp folder] contains the content of any library that was loaded at run time. Without a copy, Replay can't work reliably.

这篇关于Jenkins工作区中的@tmp文件夹是什么以及如何清理它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆