Version 8

    Better use HudsonGroovyBasedJobConfiguration as it is portable to windowses as well and more convenient generally. I doubt features of common_bash.sh are really maintained although most must work just fine.

     

    Simple example for using bash scripts can be seen here.

     

    The first line of the script must be ". $HUDSON_CONFIG_DIR/scripts/common/common_bash.sh". This includes in the shell environments useful functions like setjava, setant, kill-jboss, start-jboss, chprop and many more. It also sets some environment variables. As well it could include in the future common code that should be executed for all builds to prepare the slave.

     

     

    Look at HudsonCreateNewJob for available environment variables. Avoid using hard-coded PATHs to have a portable job across different slaves. See some more point below.

     

    $HUDSON_CONFIG_DIR variable points to a svn repository https://svn.jboss.org/repos/qa/hudson/trunk that contains most of configuration data /scripts hudson jobs use. It's highly recommended to use that repository for storing configuration data. To do that checkout the repository in your home directory. Make any changes. As first line in the script have "export HUDSON_CONFIG_DIR=/home//repos/hudson" (make sure hudson can read that). That will make job execute like you have modified the central repository but now other jobs will be safe from your mistakes. Once you are happy with config, commit changes and ask someone with sudo hudson to svn update /home/hudson/config_repository. Then disable the export line.

     

    Note the existence of $HUDSON_STATIC_ENV. This directory is for projects maintaining their own repository in the user home, or requiring ant installation modified during the build process or something. Use a directory with meaningful name under $HUDSON_STATIC_ENV for such things to keep hudson home maintainable. You can see jBPM.3 jobs on hudson have "USER_HOME=$HUDSON_STATIC_ENV; ant " and "VARNAME=" "" will expand to the current user's home dir. But not "<something> -Dvarname=".

     

    NOTE 2: Try using "~" and variables so the scripts are portable from user to user and will not fail if for some reason hudson changes home directory or something.

    NOTE 3: To see available shell functions, look at <hudson repo>/scripts/function.d . All function if not having obvious functionality should have description on top of the file. Please write functions for some stuff in your jobs that you think could be reused later.