cd /path/to/godata/plugins/external wget https://github.com/gocd-contrib/script-executor-task/releases/download/0.3/script-executor-0.3.0.jar
DOOD
我们通常希望在agent中执行docker命令在宿主中建立镜像运行容器网上大家把这种技术称之为DOOD(docker outside of docker)。 docker命令只能在root权限下执行,但是gocd的脚本是在go用户下运行的所以会报错,解决办法就是想办法让脚本切换到root下运行脚本,具体办法如下:
创建su文件
su的文件内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#%PAM-1.0 auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "wheel" group. auth required pam_wheel.so use_uid auth substack system-auth auth include postlogin account sufficient pam_succeed_if.so uid = 0 use_uid quiet account include system-auth password include syste 大专栏在Docker中运行gocdm-auth session include system-auth session include postlogin session optional pam_xauth.so
创建dockerfile制作dood-gocd镜像
1 2 3 4 5 6 7 8 9 10 11 12 13 14
FROM gocd/gocd-agent-centos-7:v18.1.0 RUN yum install -y yum-utils device-mapper-persistent-data lvm2 RUN yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo RUN yum install -y docker-ce RUN yum -y install sudo RUN echo'go ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN gpasswd -a go wheel COPY su /etc/pam.d/su RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo'Asia/Shanghai' >/etc/timezone