mirror of
https://github.com/LamGC/jenkins-agent-with-docker.git
synced 2025-07-05 06:47:25 +00:00
修复构建镜像时所创建的 docker 用户组无效的问题。
This commit is contained in:
22
start-agent.sh
Normal file
22
start-agent.sh
Normal file
@ -0,0 +1,22 @@
|
||||
if [ $(whoami) != "jenkins" ] || [ $(id -u) == "0" ]; then
|
||||
echo "This script must be run as jenkins"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$GID" ]; then
|
||||
echo "GID is not set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$UID" ]; then
|
||||
echo "UID is not set"
|
||||
exit 1
|
||||
fi
|
||||
if ! grep -q docker /etc/group; then
|
||||
groupadd -g $GID docker && usermod -aG docker jenkins
|
||||
fi
|
||||
if [ $(id -u jenkins) -ne $UID ]; then
|
||||
usermod -u $UID jenkins
|
||||
fi
|
||||
|
||||
# 使用传入的参数列表启动 Jenkins agent
|
||||
exec /usr/local/bin/jenkins-agent "$@"
|
Reference in New Issue
Block a user