Dec 9, 2014

[memo] How to change a git URL in all Jenkins jobs

Each job's configuration is saved at config.xml. So you just find old URL and change them to new URL like the below.


Sep 9, 2014

[memo] How to get hostname with logback

Just use ${HOSTNAME} logback can get hostname. Don't set hostname manually. It may make other engineers try to fix problem on other server. It's my experience. :)

Aug 13, 2014

[git] How to split repository by sub directories and retain all branches and tags

Because of Legacy and Enterprise code, I have a very big git repository moved from svn. If I build and deploy a external API's client, other clients are also updated and I should spent time to find why my war file has so many differences between current and new. If I fixed parent pom.xml, I could solve this problem. But I decided to split a big repository into 20 small repositories.

As usual, I Googled I found how to use git subtree to divide a sub directory to new git repository. It is very simple way!
Detach subdirectory into separate Git repository
 But it looses our commit logs and branches.

I asked Google again and found what I want.
git splitting repository by subfolder and retain all old branches
But I missed tags with this answer. Yes I know I should study myself. So I just added one more process to above.

Here is an example with github.

Make new repository on you github.
You can see how to push your project to new repository.
https://github.com/baepiff/test

git clone https://github.com/baepiff/voldemort voldemort
cd voldemort
git checkout --detach 
# delete all branches
git branch | grep --invert-match "*" | xargs git branch -D 
# get all branches
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done 
# confirm you have all branches and tags
git branch
git tag

# make another local repository
git clone voldemort voldemort2
cd voldemort2
git checkout --detach
git branch | grep --invert-match "*" | xargs git branch -D
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done
git branch
git tag 
# Isolate docs and recreate branches
# --prune-empty removes all commits that do not modify docs
# -- --all updates all existing references, which is all existing branches
git filter-branch --prune-empty --subdirectory-filter docs -- --all

# clean up git log
rm -rf .git/refs/original/*
git reflog expire --all --expire-unreachable=0
git repack -A -d
git prune

# push all branches and tags to new repository
git remote set-url origin https://github.com/baepiff/test
git push --all
git push --tags


I made separated repository shell script. I hope it helps you.
 

Jun 18, 2014

[git] how to change remote repository url

We have some development servers. We build source on the development on these servers. When I executed 'git fetch', git required another guy's password.

git fetch
#Password for 'https://another.guy@git.com':


Of course, I don't know his password. So I decided to change remote repository url. I got found the answer here.


git remote -v
#origin https://another.guy@git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url origin https://git.com/scm/xxx.git

git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

git fetch
#Username for 'https://git.com/': my.user
#Password for 'https://my.user@git.com':

Jun 15, 2014

[git] how to remove remote tag

If you just started to use maven release plug in, you would get some problems with release plug in like failed on prepare due to not exist snapshot version, or failed on prepare because of existing tag. I would like to share how to remove git tag from remote.
It's easy. Just run the following commands. That's it!

git tag -d myapp-0.0.1
git push origin :refs/tags/myapp-0.0.1


Apr 29, 2014

[memo] How to add/delete jvm options for glassfish

I need to modify jvm options of glassfish(2.1). I asked Google and found the following URLs.
http://docs.oracle.com/cd/E19879-01/820-4332/create-jvm-options-1/index.html
http://docs.oracle.com/cd/E19879-01/820-4332/delete-jvm-options-1/index.html

Here is my example.


Current glassfish has NewRatio and SurvivorRatio. So I deleted them and add new options like below.
-XX:NewRatio=1
-XX:SurvivorRatio=4
-Xms1024m
-XX:CMSInitiatingOccupancyFraction=70