For Git sprint management we follow the Git Flow model, and use Master branch for stable, and development branch for staging. We use the sprint number as the application version.
- Pull the code from
master
intodevelopment
branch - In
application.properties
change the version to0.{sprint number}.0
- Open a pull request from
development
tomaster
with titleSprint {sprint number}
- Merge the pull request to master
- Run a build on Jenkins and ensure that all the change build properly for demo
- Start a new sprint
There are five tools used to help maintain quality code.
Its good to run these tools at least once a sprint to look for code smells and potential issues.
- CodeNarc for Groovy and Grails static analysis
- FindBug for more analysis of the compiled Groovy code and templates
- ESLint for static analysis of JavaScript
- Remark Lint for analysis of Markdown documentation
- CSSComb for automatic formatting of style sheets
- CodeNarc is bundled with the grails application, nothing needed here
- Findbugs can be downloaded here
- One command to install the rest
npm install
- open a terminal in the imods project folder
- run
grails codenarc
- open the generated
static-analysis.html
file - resolve as many errors as possible
- open a terminal in the imods project folder
- run
grails war
- open findbug application
- file > load
- open
target/imod.war
- wait 5 minutes for it to process
- filter by package
imod
- resolve as many errors as possible
- open a terminal in the imods project folder
- run
npm test
- errors will be displayed in the terminal
- resolve as many errors as possible
- open a terminal in the imods project folder
- run
npm run comb
- code will be auto formatted, commit the updated code
There are three main package managers that are used in the project.
- Gant/Maven Manages Groovy on Rails packages
- Bower Manages UI libraries
- NPM manages UI testing libraries
- open a terminal in the imods project folder
- run
grails list-plugin-updates
- Look for plugins updates that are not labeled
snapshot
- Look up any plugins that meet the above on the grails plugin site
- Check for any breaking changes in the change logs
- Update the version to the latest stable version in the
/grails-app/conf/BuildConfig.groovy
file
- open a terminal in the imods project folder
- run
bower list
- Update the version number in
bower.json
- open a terminal in the imods project folder
- run
npm update --save-dev
- retest code with
npm test
- SSH into the server
- run
sudo apt-get update
- run
sudo apt-get dist-upgrade
- SSH into the server
- Run
sudo reboot
- Wait a few minutes
- SSH into the server again
- Run
sudo /usr/local/apache2/bin/apachectl start
- Run
sudo /opt/apache-tomcat-{version}/bin/startup.sh
Sometimes when dependencies get updated Travis CI say all builds fail.
- Check the logs to make sure it is not a code mistake
- Goto the Travis CI website
- Login with Github credentials
- Click Settings > Caches
- Click Delete all repository caches
Done! the next Travis CI build will be a bit slow, but will not hang on installing dependencies.
- SSH into the server
- Goto
/opt
- Run
sudo /opt/apache-tomcat-{old version}/bin/shutdown.sh
- Open the Apache Tomcat site
- Get the latest code binary version
sudo wget http://link-from-site.tar.gz
- Unzip file
sudo tar -zxvf apache-tomcat-version.tar.gz
- Copy the Tomcat Manager configuration from the old Tomcat config file to the new
- In
bin/catalina.sh
copy the Java version and Java Opts from the old tomcat to the new - Run
sudo /opt/apache-tomcat-{new version}/bin/startup.sh
- SSH into the server
- Goto
/opt
- Open the Node JS downloads page
- Get the latest 32bit binary
sudo wget {link from site}.tar.gz
- Unzip the file
sudo tar -zxvf {downloaded file}.tar.gz
- cd into the new version
- run
sudo ./bin/npm install -g bower
- update the path to Node JS in each of the Jenkins project configurations
- Restart apache 2 server - sudo service apache2 reload
- Start Tomcte server - sudo /opt/tomcat/apache-tomcat-7.0.63/bin/startup.sh
- Restart Jenkins - sudo /etc/init.d/jenkins restart
- Restart Postgres - sudo /etc/init.d/postgresql restart
- Run postgres in debug mode - sudo -u postgres -i /usr/lib/postgresql/8.4/bin/postgres -d 3 -D /var/lib/postgresql/8.4/main -c config_file=/etc/postgresql/8.4/main/postgresql.conf
- Run tomcat in debug mode - sudo /opt/tomcat/apache-tomcat-7.0.63/bin catalina.sh run
- List all listening ports - sudo netstat -plnt
-
Configure Services
i. Java sudo apt-get update sudo apt-get install default-jre sudo apt-get install default-jdk (Optional) sudo apt-get install oracle-java8-installer
Set environment variable JAVA_HOME="/usr/lib/jvm/java-8-oracle" source /etc/environment
ii. Postgres
sudo apt-get update sudo apt-get install postgresql postgresql-contrib phppgadmin
-Create imods user sudo -u postgres psql --command "CREATE USER imod WITH PASSWORD 'imod4u'"
-Create imod db sudo -u postgres createdb --owner imod imod-test sudo -u postgres createdb --owner imod imod-demo
iii. Grails
-if zip and unzip not installed (sudo apt-get install zip, sudo apt-get install unzip) unzip grails sdk into export GRAILS_HOME=/opt/grails-2.4.3 export GRAILS_HOME=/opt/grails-2.4.3 export PATH=$GRAILS_HOME/bin:$PATH
iv. Jenkins -add the repository key to the system. wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
-append the Debian package repository address to the server's sources.list https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list sudo apt-get update sudo apt-get install jenkins
v. Node JS sudo apt-get update sudo apt-get install nodejs sudo apt-get install npm
vi. Apache tomcat. Download Apache tomcat 7.0.63 (Or preferred version) and extract in /opt directory
-
Static data Migration.
i. Copy all the files from /opt/tomcat/apache-tomcat-7.0.63/webapps$ of old server to same folder in new server ii. Copy all the files from /var/www/html$ of old server to same folder of new server.