Tag Archives: CICD

[Solved] jenkins-deleteDir Error (FilePath is missing)

Today’s development feedback has been using the good Jenkins compilation service, but it reported an error

Look at the log and say something is wrong with deletedir

org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node

Then after development and adjustment

Start reporting another error

After developing no solution, he found me

I looked at the pipeline

pipeline {
    agent{ label 'qa-gpu016.test.cn' }
    parameters {
        string(defaultValue: '0.0.0', description: '版本号', name: 'version', trim: false)
    }
......

The discovery task is scheduled to · qa-gpu016 test.cn , and then log in to qa-gpu016 test.cn View

It was found that the disk was full. Because I didn’t know who to clean, I could only clean some unused images and containers

root@qa-gpu016:/# docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              12                  5                   21.67GB             20.58GB (94%)
Containers          6                   6                   4.765MB             0B (0%)
Local Volumes       544                 2                   197.3GB             197.1GB (99%)
Build Cache         0                   0                   0B                  0B
root@qa-gpu016:/home# docker system prune -a 
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all images without at least one container associated to them
        - all build cache
Are you sure you want to continue?[y/N] y
Deleted Containers:
e0a493a142c680033c0bce6eed8e2ee3538b6e967077c6d8e27110d992ae543e
d0283ada7950f92dbf43f02a543a12eb4efc0a1a285516500ae2ccbd87ad58f7
fbaba3555782cace190c5d8c471ab302b0a9ed8372f881899c3c421aaac96a32
facab655ec5f0bc7a1737ced60353be2c6a51a79f80cfcec04bc2b63c802fe5f
095d2f0c22483c7515c2a17bb19489fe4f52cd7251ff865bd23893ae7064e015
db4614f42fe72795335af99b64fbac7f3b41311631d349511b593b186acb6e53
4fc5b1870cb1fb4ddd5197d70b0f80ef8be224229417d0ea7b5e5f3ce94da214
53d9edf531c88c27cb31b0039427cb0bc9f7a5d8806ebda608f7bb604252fcb5
8d150da1189ba204d318cb8e028c47d71df4be0ff23a69bb1fe6a0403e938313

Deleted Images:
untagged: be510_test:0.0.217
deleted: sha256:cc9822c1c293e75b5a2806c2a84b34b908b3768f92b246a7ff415cf7f0ec0f37
deleted: sha256:f21a13c9453fb0a846c57c285251ece8d8fc95b803801e9f982891659217527a
deleted: sha256:38c1da0485daa7b5593dff9784da12af855290da40ee20600bc3ce864fb43fc0
......
root@qa-gpu016:/#

Then inform the developer to remove the judgment and keep it as it is

......
        cleanup {
            /* clean up our workspace */
                deleteDir()
                
            /* clean up tmp directory */
            dir("${workspace}@tmp") {
                deleteDir()
            }
            /* clean up script directory */
            dir("${workspace}@script") {
                deleteDir()
            }
        }
......

Reconstruction, development feedback, pulling an image, and now entering the compilation process. Before, an error was reported on the outside

So far, the problem has been solved