Jenkins GoGS integration with webhook

Please use deployment from this article to install and configure full topology which we need.

In the ‘git bash‘ generate some ssh keys which will be used from Jenkins to the GoGS. Copy public key and add this key in the GoGS.

$ ssh-keygen -b 2048 -t rsa -f gogs -q -N ""
$ cat
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCg8o5mTDO/5EmL5uiMi1UFB+yTVuSPJkZXIKFuKTKYBAZSwTFEPUG3RYmvrTo0PUf14ocNj2EccuHEz2Bz0XVisHDPdp3bEcD7RoR+EKyVKHLZ2vL1QVUiBe9nywbPu0VWL9x1Dy05P8weuqQqnuTMtGXGjcUf97km4CiX+5wUG6++4da5G/VfaeM09QZ6xbpwmZXyvpLV0CuhyzBjxzH6RArYAncyF5jeWlKCWkM42OjW+S7Ch9oO86K8LCE8ksOW5u6gfAiFG5bFy7XZZirnF8wT2NZatCgbWpFtfnxCZDJIXm3m4qDfT/+eASIM9nn4yphjdlXpBpkhoJ4dXBB9 User@DESKTOP-SHSRIMD

Install ‘GoGS plugin‘ in the Jenkins. Go to the Main menu -> Manage Jenkins -> Manage Plugins -> Go to the Available tab -> In the search filter enter ‘Gogs Plugin‘ -> Select checkbox and press ‘Download now and install after restart‘ button

Add new ‘SSH Username with private key‘ credential which will be used to clone codes from GoGS. Enter directly private key which generated before

Add new ‘Freestyle project‘ to test gogs. Go to Jenkins main menu -> New Item -> enter name ‘Jenkins-GoGS-Trig‘ -> Press OK button

Under ‘General‘ tab select checkbox ‘Use Gogs secret

Generate some random password(This is will be used as API token between GoGS and Jenkins. Copy this secret in some secure place because we will need this in GoGS configuration) and paste inside of ‘secret‘ line

Under ‘Source Code Management‘ press ‘Git‘ enter GoGS repository URL (git@ which will be created, select Credential for git and press ‘Apply‘ button

To clean workspace before each build, just select checkbox ‘Delete workspace before build starts‘ under ‘Build Environment

At the end of page in the ‘Build‘ section press ‘Add build step‘, select ‘Execute shell‘ then add ‘cat‘ command (it will print all lines which came from gogs repository) to check trigger and press ‘Save‘ button

In the GoGS interface create new repository. Press plus button (username: gogs and password: gogspassword from script in the git repository):

Enter name, repo will be private and press ‘Create Repository‘ button.

Clone this repository and add some file. Disable SSC checking.

$ git config --global http.sslVerify false
$ git clone
Cloning into 'jenkins-gogs'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ cd jenkins-gogs/
$ echo 'Added README' >
$ git add
$ git commit -m "Added README"
$ git push

Under your profile press ‘Your Settings‘ button

Then press ‘SSH Keys‘ and then ‘Add Key

Add public key which created before and press ‘Add Key‘ button

Then go to the Settings -> Webhooks -> Add Webhook

Select ‘Gogs

In the opened page we will configure GoGS to send information to the Jenkins. In the Payload URL add line as following syntax

In the secret line add before generated random password for API which used in Jenkins. Select event types for your need and then press ‘Add Webhook‘ button

In the opened page press to edit button:

Then press to the ‘Test Delivery‘ button and look at the Recent Deliveries

Add some line to readme and push to check result:

$ echo "This line will be printed in the Jenkins build output to see the reult" >
$ git add
$ git commit -m "Added check jenkins"
$ git push

At the same time go to check Jenkins side. As we see the trigger is worked.

Look at the line which printed from file:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s