How to solve jenkins 'Disk space is too low' issue?

前端 未结 8 1257
南笙
南笙 2021-01-31 07:40

I have deployed Jenkins in my CentOS machine, Jenkins was working well for 3 days, but yesterday there was a Disk space is too low. Only 1.019GB left.

相关标签:
8条回答
  • 2021-01-31 08:37

    To check the free space as Jenkins Job:

    Parameters

    • FREE_SPACE: Needed free space in GB.

    Job

    #!/usr/bin/env bash
    
    free_space="$(df -Ph . | awk 'NR==2 {print $4}')"
    
    if [[ "${free_space}" = *G* ]]; then
      free_space_gb=${x/[^0-9]*/}
    
      if [[ ${free_space_gb} -lt ${FREE_SPACE} ]]; then
        echo "Warning! Low space: ${free_space}"
        exit 2
      fi
    else
      echo "Warning! Unknown: ${free_space}"
      exit 1
    fi
    
    
    echo "Free space: ${free_space}"
    

    Plugins

    Set build description

    Post-Build Actions

    • Regular expression: Free space: (.*)
    • Description: Free space: \1

    • Regular expression for failed builds: Warning! (.*)

    • Description for failed builds: \1
    0 讨论(0)
  • 2021-01-31 08:43

    Beside above solutions, there is a more "COMMON" way - directly delete the largest space consumer from Linux machine. You can follow the below steps:

    1. Login to Jenkins machine (Putty)
    2. cd to the Jenkins installation path

    Using ls -lart to list out hidden folder also, normally jenkin installation is placed in .jenkins/ folder

    [xxxxx ~]$ ls -lart

    drwxrwxr-x 12 xxxx 4096 Feb 8 02:08 .jenkins/

    1. list out the folders spaces

    Use df -h to show Disk space in high level

    du -sh ./*/ to list out total memory for each subfolder in current path.

    du -a /etc/ | sort -n -r | head -n 10 will list top 10 directories eating disk space in /etc/

    1. Delete old build or other large size folder

    Normally ./job/ folder or ./workspace/ folder can be the largest folder. Please go inside and delete base on you need (DO NOT delete entire folder).

    rm -rf theFolderToDelete

    0 讨论(0)
提交回复
热议问题