jenkins使用docker启动
version: '3.7' services: jenkins: #image: jenkins/jenkins:2.318 image: harbor.jiangxingai.com/library/jxjenkins/x8664/others:2.0.1 container_name: jenkins environment: - TZ=Asia/Shanghai volumes: - /var/run/docker.sock:/var/run/docker.sock # - /usr/bin/docker:/usr/bin/docker - /mnt/datadisk0/jenkins:/var/jenkins_home ports: - "8080:8080" privileged: true user: root restart: always mysql: image: harbor.jiangxingai.com/library/jxasp-mysql/x8664/others:2.1.0 restart: always ports: - "3336:3306" environment: - TZ=Asia/Shanghai - MYSQL_ROOT_PASSWORD=jiangxing123asp volumes: - /etc/localtime:/etc/localtime:ro - /mnt/datadisk0/jenkins/db:/var/lib/mysql
1、给容器内安装selenium运行环境
# 换源 mv /etc/apt/sources.list /etc/apt/sources.list.bak echo -e "deb http://ftp.cn.debian.org/debian buster main \ndeb http://ftp.cn.debian.org/debian buster-updates main \ndeb http://ftp.cn.debian.org/debian-security/ buster/updates main \ndeb http://ftp.cn.debian.org/debian buster-backports main" > /etc/apt/sources.list apt update apt install vim -y # 安装python3及pip3 apt install -y python3 python3-pip pip3 install --upgrade pip apt install jq -y # pip3 安装临时换源-i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install requests xlsxwriter arrow websocket websocket selenium pytest pytest-html pyyaml BeautifulSoup4 -i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install websocket-client -i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install certifi chardet et-xmlfile idna jdcal openpyxl python-dateutil python-sonarqube-api python-gitlab six SQLAlchemy urllib3 -i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install corpwechatbot==0.6.1 PyMySQL==1.0.2 -i https://pypi.tuna.tsinghua.edu.cn/simple # 20220331补充 pip install pytest-ordering pywin32 webdriver-manager -i https://pypi.tuna.tsinghua.edu.cn/simple # 安装谷歌浏览器及驱动 apt install wget -y wget http://www.linuxidc.com/files/repo/google-chrome.list -P /etc/apt/sources.list.d/ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - apt update apt install google-chrome-stable -y #查看安装的浏览器版本 google-chrome --version wget http://chromedriver.storage.googleapis.com/95.0.4638.69/chromedriver_linux64.zip # 谷歌版本会更新 # wget http://chromedriver.storage.googleapis.com/98.0.4758.80/chromedriver_linux64.zip mv chromedriver_linux64.zip /usr/bin/ cd /usr/bin/ unzip chromedriver_linux64.zip ln /usr/bin/chromedriver /usr/local/share/chromedriver # 给容器添加运行内存,不然会报错(手动输入,复制粘贴格式有问题) mount -o remount,size=5G shm # 查看shm内存是否添加成功 df -h #基于正在运行的容器上传 docker commit 9df0b7f95bbd harbor.jiangxingai.com/library/jxjenkins/x8664/others:2.0.0 docker push harbor.jiangxingai.com/library/jxjenkins/x8664/others:2.0.0 # 安装npm环境运行apifox
浙公网安备 33010602011771号