Auto pushing to remote repository using post-commit hook not working

1,052 views
Skip to first unread message

Hemang Gandhi

unread,
Apr 2, 2018, 12:52:56 AM4/2/18
to Drools Usage
Hello,

I am able to clone an external git repository from github to KIE workbench. Once I clone, the repository is created in /bin/.niogit folder. I am looking at pushing any changes that I make in KIE workbench to external git repository. KIE workbench commits the changes to local repository but does not automatically push to external repo. So, I tried creating a post-commit hook to the .niogit/repository/hooks folder. But, it isn't triggered as soon as I make any change to the repo in KIE workbench.

Then, I tried cloning the repository from KIE workbench (localhost:9418) to another local folder. I added a post-commit hook in this locally checked out repository's hooks folder. Now if I add/update any file manually in this folder, use a tool like tortoise git and add, commit & push the new file, the file automatically gets pushed to remote github repository. I'm wondering why post-commit hook isn't working from .niogit folder. Any ideas?

The same git pull-push functionality I would like to use for adding/updating project information as well with pom.xml file. I am looking towards pulling the pom.xml file, making changes like updating the version information (externally) of the project and pushing back to KIE workbench to reflect then changes over there.

Please suggest any pointers as why post-commit is not working from .niogit folder? or if there is another/better way of updating files in KIE workbench externally.

Thanks,
Hemang

Alexandre Porcelli

unread,
Apr 2, 2018, 2:30:22 PM4/2/18
to drools...@googlegroups.com
What OS are you using? What version of Workbench are you using?

Regards,
___________________
Alexandre Porcelli
F: +1 (978) 844-8695
http://porcelli.me
> --
> You received this message because you are subscribed to the Google Groups
> "Drools Usage" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to drools-usage...@googlegroups.com.
> To post to this group, send email to drools...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/drools-usage/b22e2394-1dbe-44e8-baec-76c2025c9724%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Dhamodharan Krishnan

unread,
Apr 4, 2018, 1:14:22 AM4/4/18
to Drools Usage
You have to give the following path in the startup script.
-Dorg.uberfire.nio.git.hooks=<Folder path that contains the post-commit script>

Contents of post-commit file.

#!/bin/sh

# Git post commit hook to push the changes to the remote origin

git push origin master

echo "Pushing changes to master"

git remote set-url origin https://github.com/USERNAME/REPOSITORY.git   

Dhamodharan Krishnan

unread,
Apr 4, 2018, 1:16:03 AM4/4/18
to Drools Usage
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git

Marco Caminiti

unread,
Oct 30, 2018, 11:41:02 AM10/30/18
to Drools Usage
Hi all,

I'm trying to use git hook to alignkie-wb git repo with my own git repository.
I have set the org.uberfire.nio.git.hooks folder wich contains a post-commit file as this:

git push --set-upstream --force http://USERNAME:PASSWORD@MY_PRIVATE_GIT_REPO_URL/droolstest.git master

executing this command from bash its work fine.

At the startup of the server this file was copied into  JBOSS_HOME/bin/.niogit/droolstest.git/hooks correctly.

At this way if I modify the progect the hook was not triggered.

Do you have any suggest to resolve this?
 
PS: I want to create more then one project in Kie-Wb and for each I want to assign a different git repository, then I should have into org.uberfire.nio.git.hooks folder one post-commit file for each project, but at the startup its copy all file into the folder into hooks project subfolder. It's correct? if I not use org.uberfire.nio.git.hooks but copy manually the post-commit files the hooks shoud be triggered in the same way


beat regards 
marco Caminiti

Alexandre Porcelli

unread,
Oct 30, 2018, 11:52:24 AM10/30/18
to drools...@googlegroups.com
What version?

Regards,
___________________
Alexandre Porcelli
F: +1 (978) 844-8695
http://porcelli.me

> --
> You received this message because you are subscribed to the Google Groups "Drools Usage" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
> To post to this group, send email to drools...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/7ee908d9-be74-4429-95b2-a1e8b895f69d%40googlegroups.com.

Marco Caminiti

unread,
Oct 30, 2018, 12:01:24 PM10/30/18
to Drools Usage
7.11-Final

Alex Porcelli

unread,
Nov 5, 2018, 5:11:45 PM11/5/18
to drools...@googlegroups.com
I just bloged about how to setup hooks, let me know if it helps. If
doesn't, let me know:

http://porcelli.me/rhba/business-central/git/setup/githook/2018/11/05/business-central-git-setup-hook.html

Regards,
___________________
Alexandre Porcelli
F: +1 (978) 844-8695
http://porcelli.me
> To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/0b7ee840-824e-4ea3-a5bc-7846e93277a8%40googlegroups.com.

Marco Caminiti

unread,
Nov 6, 2018, 3:53:53 AM11/6/18
to Drools Usage
Hi Alex,

thanks for the reply. For test I was trying on windows, now I have tested it on linux (with echo only) and its work fine.

Alex Porcelli

unread,
Nov 6, 2018, 6:53:14 AM11/6/18
to drools...@googlegroups.com
Marco,

 Linux is always the best choice, no question about it  :)

 However, if you really want use Windows (besides you’re on your own :P) you need setup Cygwin.

Regards,
Alex


For more options, visit https://groups.google.com/d/optout.
--

smith

unread,
Aug 26, 2019, 8:25:05 AM8/26/19
to Drools Usage
Hi Alex,

I have gone through the blog and i was in confuse how to implement the post-commit script.

Following is the code i have written in the  post-commit.sh file as i am executing in the Linux machine.

#!/bin/sh

# Git post commit hook to push the changes to the remote origin

git push origin master

echo "Pushing changes to master"

git remote set-url origin https://ustr-bitbucket-1.na.uis.unisys.com:port/scm/project/kietestproject.git 


The above four lines are in the post-commit.sh file

and in the standalone.xml file i have mentioned the property name as follows

 <property name="org.uberfire.nio.git.hooks" value="/opt/Jboss_home/bin/.niogit/MySpace/KieTestProject.git"/>

Please give me some suggest me so that how can i proceed.








smith

unread,
Aug 26, 2019, 8:30:57 AM8/26/19
to Drools Usage
post-commit is not getting triggered. 

smith

unread,
Aug 27, 2019, 3:06:22 AM8/27/19
to Drools Usage
Hi  Marco Caminiti

Can you, please atleast expalin how can i proceed for the below problem i am facing.

It will be a great if i would get some message fro you people.

smith

unread,
Aug 27, 2019, 3:07:31 AM8/27/19
to Drools Usage


On Tuesday, August 27, 2019 at 12:36:22 PM UTC+5:30, smith wrote:
Hi  Marco Caminiti

Can you, please at least explain how can i proceed for the above problem i am facing.

Stathis Rouvas

unread,
Aug 28, 2019, 6:47:41 AM8/28/19
to Drools Usage
Hi, can you please try the following?

---START
#!/bin/bash

gitUserName='REMOTE_REPO_USER_NAME'
gitPasswd='REMOTE_REPO_PASSWD'

BBID=bbgit

#
# urlencode/urldecode scripts shamelessly copied from https://gist.github.com/cdown/1163649
#
urlencode() {
    # urlencode <string>
    old_lc_collate=$LC_COLLATE
    LC_COLLATE=C
   
    local length="${#1}"
    for (( i = 0; i < length; i++ )); do
        local c="${1:i:1}"
        case $c in
            [a-zA-Z0-9.~_-]) printf "$c" ;;
            *) printf '%%%02X' "'$c" ;;
        esac
    done
   
    LC_COLLATE=$old_lc_collate
}

urldecode() {
    # urldecode <string>

    local url_encoded="${1//+/ }"
    printf '%b' "${url_encoded//%/\\x}"
}

# - ignore system repos
[[ `git remote -v | wc -l` -eq 0 ]] && exit 0

addBBID=yes
while read gitName gitUrl gitOps; do
  [[ "$gitName" == "$BBID" ]] && addBBID=no
done < <( git remote -v )

if [[ "$addBBID" == "yes" ]]; then
  while read gitName gitUrl gitOps; do
    if [[ "$gitName" != "$BBID" ]]; then
      # projectName=`basename $gitUrl`
      basegiturl=${gitUrl#"https://"}
      workusername=`urlencode "$gitUserName"`
      workpasswd=`urlencode "$gitPasswd"`
      bburl="https://$workusername:$workpasswd@$basegiturl"
      git remote add $BBID $bburl
      break
    fi
  done < <( git remote -v )
fi

git push -u $BBID --all
---STOP
Reply all
Reply to author
Forward
0 new messages