jenkins+robotframework

创建robotframework容器

可参考Openbmc的

下载jenkins容器

#sudo docker pull jenkins/jenkins

测试jenkins

  • host内创建jenkins home目录
#mkdir jenkins_home
  • 启动容器
#sudo docker run  -v /mnt/ram0/jenkins_home:/var/jenkins_home -v /etc/localtime:/etc/localtime -p 10240:8080 jenkins/jenkins

-v /mnt/ram0/jenkins_home:/var/jenkins_home -> 挂载host目录到容器
-v /etc/localtime:/etc/localtime -> 同步host与容器时间
-p 10240:8080 -> 映射jenkins 8080端口到host 10240端口

  • 浏览器输入127.0.0.1:10240,显示jenkins登录界面

jenkins安装robot framework 插件

TODO

jenkins调用robotframework的容器

需要修改jenkins容器的启动参数,让容器内可以调用host的docker,注意添加权限设置

-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -u 0

build后打开robotframework报告失败

编译jenkins容器中的/usr/local/bin/jenkins.sh,在exec java开头的那行增加参数,修改后如下

exec java -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'u    nsafe-eval' ;" -Duser.home="$JENKINS_HOME" ${FUTURE_OPTS} "${java_opts_array[@]}" -jar ${JENKINS_WAR} "${jenkins_opts_array[@]}" "$@"

创建job执行测试

  • build参数
ROBOT_DATA=/mnt/ram0/openbmc-test-automation-master
ROBOT_OUTPUT=/mnt/ram0/robotlog
ROBOT_CASE=ipmi/test_ipmi_device_id.robot
docker run \
-v ${ROBOT_DATA}:/opt/test \
-v ${ROBOT_OUTPUT}:/opt/log \
-i 93b55ffb403f \
robot -v OPENBMC_HOST:${BMC_IP} -v IPMI_USERNAME:${BMC_USERNAME} -v IPMI_PASSWORD:${BMC_PASSWORD} -d /opt/log -l log_${BUILD_ID}.html -r report_${BUILD_ID}.html /opt/test/${ROBOT_CASE}

posted on 2022-06-15 18:45  zlyang  阅读(226)  评论(0编辑  收藏  举报

导航