在"Raspberry Pi"的QEMU仿真上设置Jenkins CI服务器(Windows)

tkh*_*lll 0 java qemu raspberry-pi raspbian

  1. 如何使用QEMU设置Raspberry'VM'
  2. 设置Jenkins以使用新的Oracle Java 7运行

tkh*_*lll 6

0.仿真

  1. 下载并解压缩http://sourceforge.net/projects/rpiqemuwindows/
  2. 通过运行run.bat启动QEMU
  3. 安装和配置Raspbian(用户:pi,密码:raspberry)
  4. 关闭QEMU

vm-image有一个非常小的驱动器,大约300MB的可用空间,这还不足以安装Java + Jenkins.所以我们需要扩展它.

1.扩大音量

  1. rasptroy图像扩展为10GB,qemu-img resize 2012-07-15-wheezy-raspbian.img +10G
  2. 但这还不够,因为我们还需要在图像的文件系统中扩展分区.所以我们需要启动GParted live cd,因为我们不能在运行时这样做.
  3. Download GParted Live CD http://gparted.sourceforge.net/download.php
  4. Copy the files from the Bios directory into the QEMU directory, where qemu-system-x86_64.exe is located.
  5. Start a normal x86 machine using the command:

    qemu-system-x86_64.exe -hda 2012-07-15-wheezy-raspbian.img -m 512M -cdrom gparted-live-0.16.2-1b-i486.iso -boot d -pflash bios.bin.

    This take a quite bit of time...

  6. Resize the partition to fill the disk.

  7. Don't forget to actually apply before closing.
  8. Launch QEMU again and verify that the rootfs is now larger using the command df

2. Install Jenkins

  1. sudo apt-get update
  2. sudo apt-get install jenkins
  3. Stop the service sudo service jenkins stop
  4. The log cat /var/log/jenkins/jenkins.log reveals the following:

    [Winstone] - Beginning extraction from war file
    [Winstone] - Error initializing web application: prefix []
    java.io.IOException: No space left on device
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:282)
    at winstone.HostConfiguration.getWebRoot(HostConfiguration.java:273)
    at winstone.HostConfiguration.<init>(HostConfiguration.java:73)
    ...
    at Main.main(Main.java:96)
    
    Run Code Online (Sandbox Code Playgroud)
  5. Jenkins实际上已经崩溃,因为它试图将所有文件提取到tmpfs/run,其中只有10%的RAM(约20MB -m 192).要解决此问题,我们需要将--webroot参数编辑为Jenkins以使用另一个目录.
  6. nano /etc/default/jenkins 编辑以下行

    JENKINS_ARGS="--webroot=$JENKINS_RUN/war --httpPort=$HTTP_PORT ...

    JENKINS_ARGS="--webroot=$JENKINS_HOME/war --httpPort=$HTTP_PORT ...

3.安装Oracle Java 7(硬浮)

  1. run.bat再次启动QEMU
  2. sudo apt-get install oracle-java7-jdk
  3. 列出已安装的Java版本(Jenkins安装OpenJDK) update-java-alternatives -l
  4. sudo update-alternatives --config java 并选择Oracle JDK.
  5. 现在尝试java -version确保使用Java(TM)SE运行时环境

4.启动并验证安装

  1. sudo service jenkins start
  2. tail /var/log/jenkins/jenkins.log -f并等待詹金斯完全正常运行
  3. 现在尝试它实际上是 wget localhost:8080 && nano index.html