DESCRIPTION
I want to send change-log messages to all colleagues when an push is made in a particular branch (test-branch) in a mercurial repository.
Mercurial Setup
- Local cloned repository ( Local Machine of User )
- Server Repository ( On a Server, Users can push or pull changes to here from their local repositories on their machines)
- Sand-box repository ( updated parallel to the Server to keep a track & have reference)
Idea behind the bash script.
- incomming-hook on Server Repository, It triggers a bash script( bash-script1) which inturns triggers another bash script(bash-script2) that checks some conditions and send emails. bash-script 1 has two variables $HG_NODE9set by mercurial) & stderr out-put from it.
the codes are below.
1.Hook on mercurial server (/var/hg/repository/.hg/hgrc)
[hook]
incoming=/home/user/incomming
Bash-script 1 (/home/user/incomming)
nohup /usr/bin/sudo -i -u user /home/user/bin/changelog.sh $HG_NODE &>/dev/null &
Bash script 2 (/home/user/bin/changelog.sh)
#we go to the sandbox repository directory cd /home/user/hg/repository L_BRANCH_SANDBOX=$($HG branches | $GREP testbranch | $SORT -Vr |$AWK '{print $1}') P_BRANCH=$($HG log -r $HG_NODE | $HEAD -n 4 | $GREP branch: | $AWK '{print $2}') if [[ "$L_BRANCH_SANDBOX" == "$P_BRANCH" ]] ; then Some commands and send mail fi
RESULT
I see that the hook is triggered as my BASH-SCRIPT1 gives output if i put some echos at top and bottom but my BASH-SCRIPT2 doesnt even start as it doesn't even echo at the very begining. But my BASH_SCRIPT2 runs if i run it manually with a know $HG_NODE.
Thank you for your support