1

Hi anyone have a some script may be for example how I can create hook in GitLab repository to automatically build maven war archive from project after each push request? Please post some example of script! Thanks in advance!

asked Mar 1, 2014 at 21:37

2 Answers 2

3

You can use a Gitlab-API wrapper to create your hook. There are some in several languages, I'll use the Ruby wrapper as an example. Adding a hook is as simple as :

h = Gitlab.add_project_hook(project_id, hook_url)

Of course, check first if the hook doesn't already exist. Your url could end with /maven .

Your hook will now trigger a POST request on the url everytime something is pushed to the project repo.

A simple webserver such as Sinatra can now handle the request :

mavenjob.rb
require 'sinatra'
post '/maven' do
 'Hook triggered'!
 #Handle creation of maven archive
end

You could consider handling POST requests with a queuing system such as Resque. In case you want to go with Ruby there is a Maven wrapper on Github but I've never used it.

Hope it helps!

answered Mar 7, 2014 at 10:57
Sign up to request clarification or add additional context in comments.

Comments

0

My recomodation is to configure gitlab-ci and use it toghether with gitlab. You can also run some other things there and it has very good interface.

answered Apr 2, 2014 at 15:52

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.