问题描述
我已经安装了Jenkins并配置了一个构建作业,并在构建过程中运行了模拟器.但是,当我执行作业时,我收到错误消息,表明jenkins用户没有运行kvm的权限.我该如何解决.
I have installed Jenkins and configured a build job with emulator running during build. But when I execute the job, I get error message that jenkins user doesn't have permission to run kvm. How can I fix it.
$ android list target
[android] Using Android SDK: /opt/android/sdk
$ adb start-server
* daemon not running. starting it now on port 5973 *
* daemon started successfully *
$ adb start-server
[android] Starting Android emulator
[android] Erasing existing emulator data...
$ emulator -ports 5971,5972 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_160_1024x768_android-15_x86 -no-snapshot-load -no-snapshot-save -wipe-data
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm).
[android] Emulator did not appear to start; giving up
$ adb disconnect localhost:5972
[android] Stopping Android emulator
$ adb kill-server
权限
$ ls -l /dev/kvm
crw-rw----+ 1 root root 10, 232 May 6 13:46 /dev/kvm
$ groups jenkins
jenkins : jenkins
推荐答案
我设法解决了这个问题.
I have managed to fix the problem.
-
安装Qemu-KVM和cpu-checker
Install Qemu-KVM and cpu-checker
apt-get install qemu-kvm cpu-checker
检查KVM是否可用(以jenkins用户身份
Check if KVM is available (as jenkins user
$ kvm-okINFO: /dev/kvm existsKVM acceleration can be used
$ kvm-okINFO: /dev/kvm existsKVM acceleration can be used
创建组kvm并将詹金斯添加到该组
Create group kvm and add jenkins to this group
addgroup kvmusermod -a -G kvm jenkins
addgroup kvmusermod -a -G kvm jenkins
更改/dev/kvm
chgrp kvm /dev/kvm
创建udev规则
$ sudo nano /etc/udev/rules.d/60-qemu-kvm.rulesKERNEL=="kvm", GROUP="kvm", MODE="0660"
$ sudo nano /etc/udev/rules.d/60-qemu-kvm.rulesKERNEL=="kvm", GROUP="kvm", MODE="0660"
重新启动
这篇关于在詹金斯构建过程中运行android模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!