Published - 6 years ago ( Updated - 6 years ago )
How to use Gogs to trigger Jenkins to test and deploy Pipline.
We can obtain it from the upper right "User Name"=>"Settings"=>"API Token" button
User ID and API Token.

In addition, Token can be set under the tab of Build Triggers.

The above three pieces of information can be combined to generate the trigger URL.
Therefore, to manage Git hooks in Gogs, you can set it as follows: (Please use the https URL, the diagram below)
The post-receive hook of git will be triggered when the user pushes.

As an aside, the actions to be performed after the post-receive hook is triggered can vary according to different environments.
For example, in docker swarm mode, to mount the same folder, it may be set like this:
The following can be imagined as entering the folder of the working directory, ignoring any changes in /sites/www, and forcing the update to the repo version.
Let's look back at the pipline part of Jenkins. In the Laravel environment, the configuration is quite simple.
Regarding Pipline, it can be downloaded in a similar way...

Why can git@gogs:devin/proj1.git download the repo, because I added the name of gogs in the .ssh/config (SSH connection configuration setting) of jenkins.
The test results are as follows, when I push changes from the client side, it will... trigger the pipeline detection.

The following are built using the docker-compose environment
The docker-compose version of Gogs:
https://github.com/DevinY/gogs
Articles about Gogs: (Use docker-compose to quickly build a private git service)
https://www.ccc.tc/article/setup-your-private- git-hosting-with-gogs
This is the version of docker-compose I use: (php in this article has been updated to PHP 7.2.6)
https://github.com/DevinY/jenkins
If you want to know about the settings of Pipeline, please refer to my other article:
https://www.ccc.tc/article/laravel-automation-and- testing-with-jenkins-pipeline
http://{USER}:{API_TOKEN}@{JENKINS_URL}/job/{JOB}/build?token= {AUTHENTICATION_TOKEN}
We can obtain it from the upper right "User Name"=>"Settings"=>"API Token" button
User ID and API Token.

In addition, Token can be set under the tab of Build Triggers.

The above three pieces of information can be combined to generate the trigger URL.
Therefore, to manage Git hooks in Gogs, you can set it as follows: (Please use the https URL, the diagram below)
The post-receive hook of git will be triggered when the user pushes.

As an aside, the actions to be performed after the post-receive hook is triggered can vary according to different environments.
For example, in docker swarm mode, to mount the same folder, it may be set like this:
The following can be imagined as entering the folder of the working directory, ignoring any changes in /sites/www, and forcing the update to the repo version.
#!/bin/sh
GIT_WORK_TREE=/sites/www git checkout -f
Or push -f again to force update the repo of the remote host, and post-recieve the remote host to update to production.
#!/bin/bash
git push -f dlaravel_source:/source/api master
Or use rsync to update, it depends on everyone's imagination. Let's look back at the pipline part of Jenkins. In the Laravel environment, the configuration is quite simple.
Regarding Pipline, it can be downloaded in a similar way...

Why can git@gogs:devin/proj1.git download the repo, because I added the name of gogs in the .ssh/config (SSH connection configuration setting) of jenkins.
Host gogs
Hostname 192.168.100.2
User git
IdentityFile=~/.ssh/id_rsa
Port 10022
The test results are as follows, when I push changes from the client side, it will... trigger the pipeline detection.

The following are built using the docker-compose environment
The docker-compose version of Gogs:
https://github.com/DevinY/gogs
Articles about Gogs: (Use docker-compose to quickly build a private git service)
https://www.ccc.tc/article/setup-your-private- git-hosting-with-gogs
This is the version of docker-compose I use: (php in this article has been updated to PHP 7.2.6)
https://github.com/DevinY/jenkins
If you want to know about the settings of Pipeline, please refer to my other article:
https://www.ccc.tc/article/laravel-automation-and- testing-with-jenkins-pipeline
No Comment
Post your comment