First of all, I want to explain the background of developing Gitlab-Robot-Jenkins because of the project (github.com/shuidi-fed/...). This project just makes a simple message robot function, and it is not smooth to use, which gives me the inspiration to improve it. Combined with the situation of our company, I have sorted out and summarized some problems existing in the project merger message notification and the construction and release process.
The summary is as follows
1: When a developer adds a merge request to GitLab, he/she needs to notify the code_reivew reviewer in the enterprise wechat group
Step 2: When a code_review reviewer clicks merged, it is not always possible to alert the developer in a timely way, so ask them in person.
Step 3: When the developer receives merged notification, go to Jenkins and select View - Job - Branch to build the deployment. The whole process is cumbersome to operate and repeats itself with each build.
? shows that our company has some problems in working efficiency and communication cost. After a few days of research, I started to develop this Chrome extension: Gitlab-Robot-Jenkins. Its original intention is to smoothly connect gitLab, Robot and Jenkins.
The general process is shown in the figure below:
Next, I would like to share with you some of the questions and thoughts I encountered during the development process of gitlab-Robot-Jenkins plug-in:
- How to update and maintain the data relationship among (Gitlab, Robot, Jenkins)?
- How to make GitLab and Robot achieve seamless cooperation?
- How to get Jenkins' data and get through the process of construction, deployment and release?
1. How to update and maintain the data relationship among gitLab, Robot and Jenkins?
My approach is to add and maintain a Gitlab-Rot-Jenkins project file: fe.json on Gitlab. This file (fe.json) is only the relational data used by colleagues in the front-end group, and other teams can similarly maintain a set of relational data according to the specification. Then by gitlab API to access data (docs.gitlab.com/ee/api/repo...). ", which makes it easier to maintain and update.
Fe. json file data
2. How to make GitLab and Robot cooperate seamlessly?
One way to make gitLab and Robot work seamlessly is to make chrome Extension solutions.
Advantages of Chrome Extension: you can modify the DOM structure of the page and inject files on the **** page.
The relational data we maintain through Gitlab-robot-Jenkins allows matching items to be tagged as message bots. The Submit Merge Request button and merge button are then inserted with the operation of the message robot.
3. How to obtain Jenkins' data and get through the process of construction, deployment and release?
Here is where Jenkins package (www.npmjs.com/package/jen.) . Do not use user.pass. If you do not use jenkins.job. Build, do not use jenkins.job.
In jenkins.job. Build, name is the name of the target job for construction, and in parameters, variable parameter values required for construction. Our operation and maintenance personnel helped us to build it in advance. We can see that JK_Branch is the branch of the project to build, and the other parameters are the default values by default. The parameters vary from company to company and need to be set accordingly. We can see that the parameters in "jenkins_job_build_params" are name and parameters.
After the configuration, you can get all the data of the view and job smoothly.
Below are all views and jobs on Jenkins.
The gitlab-Robot-Jenkins plugin has the following functions:
- Jenkins build deployment
- Gitlab code review
- Robot Message Template
1. Jenkins builds deployment
After configuring the Jenkins User Authorization address (baseUrl), you can operate the Jenkins API.
We can save build history to generate a card record, and we can quickly customize cards so that next time we can easily complete one-click deployment.
2. Gitlab code review
The gitlab-Robot-Jenkins relational data is our FE. json data. We can by gitlab API to access data (docs.gitlab.com/ee/api/repo...). . Each project needs to specify a corresponding Code_review person, and each person is different.
3. Robot message template
If you find it helpful, please like ??? to support it.
I am currently looking for a job