问题是让Jenkins在节点上安装Groovy

huangapple go评论53阅读模式
英文:

Problem letting Jenkins install Groovy on nodes

问题

我正在尝试在Jenkins中设置Groovy,以便在执行作业时自动安装在代理上。

这是我的全局配置:

问题是让Jenkins在节点上安装Groovy

这是我的Groovy构建步骤:

问题是让Jenkins在节点上安装Groovy

当我运行作业时,我收到以下错误:

问题是让Jenkins在节点上安装Groovy

用户testrpm确实具有sudo权限。问题出在哪里?

英文:

I'm trying to setup Groovy in jenkins, so that it automatically is installed on an agent when performing jobs on it.

This is my global configuration:

问题是让Jenkins在节点上安装Groovy

This is my groovy build-step:

问题是让Jenkins在节点上安装Groovy

When I run the job, I get this error:

问题是让Jenkins在节点上安装Groovy

The user testrpm does have sudo rights. Where is the problem ?

答案1

得分: 1

I wouldn't install groovy on agent nodes. You should just use groovy wrapper which will download the groovy and run that without needing to install anything into directories jenkins doesn't have permissions for.

Short of that I would NOT grant sudo rights to testrpm either. That's going to be bad mojo. Instead you can add testrpm to a group that allows right access to /opt or /opt/groovy-4.0.0. You are unzipping something into a nested directory so you'll have to grant access to /opt to write to that directory which could be dangerous if you have other things in that directory. You may nest it in a subdirectory to isolate it from other things. If you do these steps on the machine using a user with sudo rights (not in your build script) then it should work:

sudo mkdir /opt/jenkins
sudo chgrp jenkins /opt/jenkins
sudo usermod -a -G jenkins testrpm
sudo chmod 770 /opt/jenkins

Another option would be to pick a directoy testrpm already has write access to that without needing to grant permissions to it.

英文:

I wouldn't install groovy on agent nodes. You should just use groovy wrapper which will download the groovy and run that without needing to install anything into directories jenkins doesn't have permissions for.

Short of that I would NOT grant sudo rights to testrpm either. That's going to be bad mojo. Instead you can add testrpm to a group that allows right access to /opt or /opt/groovy-4.0.0. You are unzipping something into a nested directory so you'll have to grant access to /opt to write to that directory which could be dangerous if you have other things in that directory. You may nest it in a subdirectory to isolate it from other things. If you do these steps on the machine using a user with sudo rights (not in your build script) then it should work:

sudo mkdir /opt/jenkins
sudo chgrp jenkins /opt/jenkins
sudo usermod -a -G jenkins testrpm
sudo chmod 770 /opt/jenkins

Another option would be to pick a directoy testrpm already has write access to that without needing to grant permissions to it.

huangapple
  • 本文由 发表于 2023年2月19日 20:22:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500111.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定