Jenkins管道将conan.tmpxxxxx dirs留在工作空间下

时间:2018-08-24 10:31:31

标签: jenkins jenkins-pipeline artifactory conan

背景,我们刚刚开始使用柯南,并且希望将其与Jenkins管道构建集成,这对我们来说也是新的。

我有一个简单的管道作业,该循环作业遍历yaml文件以发现产品中使用的组件,然后调用另一个管道UploadRecipe,该管道下载组件源,查找配方并将它们上载到相关的人工仓库中

但是,它在工作区/ UploadRecipe @ tmp中留下了一堆conan.tmp目录。

$ pwd /jenkins_conan/workspace/UploadRecipe@tmp 
$ ls -1
conan.tmp1453946246097996081
conan.tmp2037444640117259875
conan.tmp3926464088111486375
conan.tmp7293377119892400567
conan.tmp868991149159211380

管道并没有失败,但是它们从未被清理过,它也发生在其他与柯南相关的管道中,我们用来生成消耗GB的大型iso文件,但是Upload配方示例更容易解释和显示相同的内容行为。

我的管道常规脚本有什么问题吗?

即我应该打电话来整理一些命令吗?

properties([parameters([string(description: 'Name/Version', name: 'name_version', defaultValue: 'base/1.0.2'),
                        string(description: 'User/Channel', name: 'user_channel', defaultValue: 'release/stable'),
                        string(description: 'SVN repository branch', name: 'svn_repo_branch', defaultValue: 'tags/CONAN_REL_1.0.2'),
                        string(description: 'SVN repository url', name: 'svn_repo_url', defaultValue: 'svn+ssh://$USER@svnserver/svncmake/base/'),
                        string(description: 'Artifactory', name: 'artifactory', defaultValue: 'my-artifactory'),
                        string(description: 'Upload repo', name: 'uploadRepo', defaultValue: 'stable-release')
                       ])])

node('buildserver') {
    withEnv(['PATH+LOCAL_BIN=/xxxxx/release/.virtualenvs/jfrog/bin']) {
        currentBuild.displayName = params.name_version + "@" + params.user_channel
        def server
        def client
        def uploadRepo
        def mysvncreds = 'creds-for-svn'
        def SVN_repo_url

        deleteDir()

        stage("Configure/Get recipe"){

            server = Artifactory.server params.artifactory
            client = Artifactory.newConanClient()

            uploadRepo = client.remote.add server: server, repo: params.uploadRepo

            dir("_comp_repo"){
                SVN_repo_url = params.svn_repo_url + params.svn_repo_branch
                checkout([$class: 'SubversionSCM', locations: [[credentialsId: mysvncreds, depthOption: 'files', ignoreExternalsOption: true, local: '.', remote: SVN_repo_url ]]])
            }
        }

        stage("Export recipe"){
            dir("_comp_repo"){
                myrecipes = ['conanfile.py', 'conanfile_policy.py', 'conanfile_rpm.py']

                for(int i = 0; i < myrecipes.size(); i++) 
                { 
                    def thisrecipe = myrecipes[i]
                    if (fileExists(thisrecipe)) {
                        mycommand = "export ./" + thisrecipe + " "  + params.user_channel
                        client.run(command: mycommand )
                    } else {
                        echo thisrecipe
                    }
                }
                client.run(command: "search" )
            }
        }

        stage("Upload recipe to Artifactory"){
            def name_version = params.name_version
            string myname = name_version.split("/")[0]
            string myversion = name_version.split("/")[1]
            String command = "upload ${myname}*/*@${params.user_channel} -r ${uploadRepo} --all --confirm --retry 3 --retry-wait 10"

            client.run(command: command)
        }
    }
}

1 个答案:

答案 0 :(得分:0)

使用bash进行查找并删除

find /jenkins_conan/workspace/UploadRecipe@tmp -type f -name 'conan.tmp*' -exec rm -v {} \;

或尝试将其添加到您的管道中

node('yournode') {
     ..
    stage 'removing cache files'
    def ws = pwd()
    def file = ws + '/conan.tmp*'
    sh 'rm ' + file + ' -rf' 
}