1
|
#!/bin/bash
|
2
|
###
|
3
|
# Continous intergration build with jenkins
|
4
|
# call this script from within jenkins with:
|
5
|
# > bash -e $WORKSPACE/jenkins-ci/integration.sh $JOB_NAME $dbUser $dbPassword
|
6
|
#
|
7
|
# USAGE:
|
8
|
#
|
9
|
# references:
|
10
|
# http://thinkshout.com/blog/2010/09/sean/beginners-guide-using-hudson-continuous-integration-drupal
|
11
|
# http://drush.ws/help/3
|
12
|
###
|
13
|
# The following variables are available to shell scripts
|
14
|
#
|
15
|
# BUILD_NUMBER
|
16
|
# The current build number, such as "153"
|
17
|
# BUILD_ID
|
18
|
# The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
|
19
|
# JOB_NAME
|
20
|
# Name of the project of this build, such as "foo"
|
21
|
# BUILD_TAG
|
22
|
# String of "hudson-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
|
23
|
# EXECUTOR_NUMBER
|
24
|
# The unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
|
25
|
# NODE_NAME
|
26
|
# Name of the slave if the build is on a slave, or "" if run on master
|
27
|
# NODE_LABELS
|
28
|
# Whitespace-separated list of labels that the node is assigned.
|
29
|
# JAVA_HOME
|
30
|
# If your job is configured to use a specific JDK, this variable is set to the JAVA_HOME of the specified JDK. When this variable is set, PATH is also updated to have $JAVA_HOME/bin.
|
31
|
# WORKSPACE
|
32
|
# The absolute path of the workspace.
|
33
|
# HUDSON_URL
|
34
|
# Full URL of Hudson, like http://server:port/hudson/
|
35
|
# BUILD_URL
|
36
|
# Full URL of this build, like http://server:port/hudson/job/foo/15/
|
37
|
# JOB_URL
|
38
|
# Full URL of this job, like http://server:port/hudson/job/foo/
|
39
|
# SVN_REVISION
|
40
|
# For Subversion-based projects, this variable contains the revision number of the module.
|
41
|
# CVS_BRANCH
|
42
|
# For CVS-based projects, this variable contains the branch of the module. If CVS is configured to check out the trunk, this environment variable will not be set.
|
43
|
#
|
44
|
WORKSPACE=$1
|
45
|
JOB_NAME=$2
|
46
|
drupalRoot=/var/www/drupal/
|
47
|
drupalSiteName="jenkins"
|
48
|
drupalInstallationProfile="CDM_DataPortal"
|
49
|
|
50
|
dbName="jenkins_$JOB_NAME"
|
51
|
dbUser=$3
|
52
|
dbPassword=$4
|
53
|
|
54
|
# copy installation profiles
|
55
|
echo ">>> workspace is $WORKSPACE"
|
56
|
echo "${WORKSPACE}profile/* ${drupalRoot}profiles/"
|
57
|
cp -R ${WORKSPACE}profile/* ${drupalRoot}profiles/
|
58
|
|
59
|
# drop all tables in database
|
60
|
MYSQLCMD="mysql --user=$dbUser --password=$dbPassword -D $dbName"
|
61
|
echo $MYSQLCMD
|
62
|
$MYSQLCMD -BNe "show tables" | awk '{print "set foreign_key_checks=0; drop table `" $1 "`;"}' | $MYSQLCMD
|
63
|
unset MYSQLCMD
|
64
|
|
65
|
# install drupal site
|
66
|
echo "installing drupal site ..."
|
67
|
cd $drupalRoot
|
68
|
DRUSH="drush --uri=http://160.45.63.201/dataportal/jenkins/"
|
69
|
## drush si only works with drupal 7 so the folowing does not yet work
|
70
|
#yes | drush si --profile=${drupalInstallationProfile} --clean-url=0 --sites-subdir=${drupalSiteName} --db-url=mysql://${dbUser}:${dbPassword}@localhost/${dbName}
|
71
|
# and we will use a preset sub site directory and ur own install script:
|
72
|
wget -O /tmp/jenkins-drupal-install http://160.45.63.201/dataportal/jenkins/install.php?profile=CDM_DataPortal_Testing
|
73
|
|
74
|
$DRUSH vset --yes cdm_webservice_url http://160.45.63.201:8080/cichorieae/
|
75
|
|
76
|
|
77
|
|
78
|
|
79
|
|