linux jenkins 修改 默认工作空间主目录


jenkins 安装: https://zhaosongbin.blog.csdn.net/article/details/88891242

缘由

工作中,由于Jenkins默认的主目录空间太小,出现工作空间不足的问题
jenkins的默认目录是/root/.jenkins
这是系统盘,内存有限

ERROR: Step ‘Archive the artifacts’ aborted due to exception: 
java.nio.file.FileSystemException: 
/root/.jenkins/workspace/****.jar -> 
/root/.jenkins/jobs/****.jar: No space left on device
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:253)
	at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:581)
	at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
	at java.nio.file.Files.copy(Files.java:1274)
	at hudson.FilePath$CopyRecursiveLocal$1.visit(FilePath.java:2431)
	at hudson.util.DirScanner.scanSingle(DirScanner.java:49)
	at hudson.FilePath$ExplicitlySpecifiedDirScanner.scan(FilePath.java:3121)
	at hudson.FilePath$CopyRecursiveLocal.invoke(FilePath.java:2420)
	at hudson.FilePath$CopyRecursiveLocal.invoke(FilePath.java:2404)
	at hudson.FilePath.act(FilePath.java:1074)
	at hudson.FilePath.act(FilePath.java:1057)
	at hudson.FilePath.copyRecursiveTo(FilePath.java:2352)
	at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)
	at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:235)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
	at hudson.model.Run.execute(Run.java:1841)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
SSH: Current build result is [FAILURE], not going to run.

查看系统空间大小,我们能明确的看到/dev目录下只有50G的空间使用率已经100%
Filesystem              	     Type      Size     Used     Avail   Use%   Mounted on
/dev/mapper/centos-root          xfs       50G   	50G      57M     100%  /
[root@master ~]# df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        50G   50G   57M 100% /
devtmpfs                devtmpfs   16G     0   16G   0% /dev
tmpfs                   tmpfs      16G     0   16G   0% /dev/shm
tmpfs                   tmpfs      16G  8.7M   16G   1% /run
tmpfs                   tmpfs      16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/centos-home xfs       434G  761M  433G   1% /home
/dev/vda1               xfs      1014M  142M  873M  14% /boot
tmpfs                   tmpfs     3.2G     0  3.2G   0% /run/user/0


修改目录位置

修改容器中的配置

我的jenkins是在tomact容器下部署的war包

所以我要在tomact的bin目录下修改,在

#OS …上方添加配置

export JENKINS_HOME=/home/jekins
[root@master bin]# vim catalina.sh 

export JENKINS_HOME=/home/jekins
# OS specific support.  $var _must_ be set to either true or false.
cygwin=false
darwin=false
os400=false
hpux=false
case "`uname`" in
CYGWIN*) cygwin=true;;
Darwin*) darwin=true;;
OS400*) os400=true;;
HP-UX*) hpux=true;;
esac

# resolve links - $0 may be a softlink

修改 /etc/profile

在web容器启动之前修改配置

在profile文件内添加配置

export JENKINS_HOME=/home/jekins

使profile文件生效即可

source  /etc/profile

你可能感兴趣的:(jenkins,开发容器)