我爱编程

Setup CentOS selenium headless e

2017-03-24  本文已影响0人  Johnny_7774

1. Install Xvfb and dependencies:

    1) sudo yum -y install firefox Xvfb libXfont Xorg

    2) yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"

2. Download and install chrome

    1) wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

    2) sudo yum install ./google-chrome-stable_current_*.rpm

3. Configure Xvfb

    1) vi /etc/init.d/Xvfb, paste the Xvfb script with following contents: refer to the bottom of the page

    2) Modify the script access

        (1) chmod +x /etc/init.d/Xvfb

        (2) chkconfig Xvfb on

        (3) service Xvfb start

    3) Configure DISPLAY environment variable in jenkins:

        (1) Manage Jenkins -> Configure System -> Global Properties -> Environment Variables

        (2) Add a variable: name=DISPLAY, value=:7

    4) (Optional) Try run: google-chrome &Ignore the error message:Xlib:extension "RANDR" missing on display ":7".

4. Start selenium server

    1) In GCP terminal: cd to the selenium jar folder

    2) nohup java -jar ./lib/selenium-server-standalone-3.0.1.jar &

    3) Check the selenium server started status: ps -aux | grep java

    4) Add Peggy URL as jenkins env, same as configure the DISPLAY in 4.3eg. For shareDev,PeggyURL=https://project-7192975833413718180.firebaseapp.com

5. Update job script

    1) Replace peggy URL in config.xml withhttps://${PEGGYURL}.firebaseapp.com

    2) Replace firebase DB secret in FirebaseUtils.java with${FIREBASE_DB_SECRET}

    3) Configure slack channel

6. Add post action script for slack notification

    1) Refer to the setting:https://wiki.jenkins-ci.org/display/JENKINS/Slack+Plugin

    2) Custom message: "Job '${JOB_NAME} [${BUILD_NUMBER}]' (${BUILD_URL})"

    3) Other notification parameters refer to the "Jenkins”->“Manage Jenkins”->“Configure System”->”Global Slack Notifier Settings"

    4) Set job build trigger as ‘Projects to watch’ = ‘business-os/pwc-fso-larson-web-client/master’, trigger when stable


Xvfb script

#!/bin/bash

#

# /etc/rc.d/init.d/Xvfbd

#

# chkconfig: 345 95 28

# description: Starts/Stops X Virtual Framebuffer server

# processname: Xvfb

#

. /etc/init.d/functions

[ "${NETWORKING}" = "no" ] && exit 0

PROG="Xvfb"

PROG_OPTIONS=":7 -ac -screen 0 1024x768x24 +extension RANDR"

PROG_OUTPUT="/tmp/Xvfb.out"

case "$1" in

start)

echo -n "Starting : X Virtual Frame Buffer "

$PROG $PROG_OPTIONS>>$PROG_OUTPUT 2>&1 &

disown -ar

/bin/usleep 500000

status Xvfb & >/dev/null && echo_success || echo_failure

RETVAL=$?

if [ $RETVAL -eq 0 ]; then

/bin/touch /var/lock/subsys/Xvfb

/sbin/pidof -o%PPID -x Xvfb > /var/run/Xvfb.pid

fi

echo

;;

stop)

echo -n "Shutting down : X Virtual Frame Buffer"

killproc $PROG

RETVAL=$?

[ $RETVAL -eq 0 ] && /bin/rm -f /var/lock/subsys/Xvfb /var/run/Xvfb.pid

echo

;;

restart|reload)

$0 stop

$0 start

RETVAL=$?

;;

status)

status Xvfb

RETVAL=$?

;;

*)

echo $"Usage: $0 (start|stop|restart|reload|status)"

exit 1

esac

exit $RETVAL

上一篇下一篇

猜你喜欢

热点阅读