CN117827265A - Method and device for automatically synchronizing codes among Git warehouse - Google Patents
Method and device for automatically synchronizing codes among Git warehouse Download PDFInfo
- Publication number
- CN117827265A CN117827265A CN202211217730.8A CN202211217730A CN117827265A CN 117827265 A CN117827265 A CN 117827265A CN 202211217730 A CN202211217730 A CN 202211217730A CN 117827265 A CN117827265 A CN 117827265A
- Authority
- CN
- China
- Prior art keywords
- warehouse
- code
- git
- codes
- jenkins
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 25
- 230000001360 synchronised effect Effects 0.000 claims description 17
- 230000001960 triggered effect Effects 0.000 claims description 13
- 230000000737 periodic effect Effects 0.000 claims description 2
- 238000005516 engineering process Methods 0.000 abstract description 3
- 238000012545 processing Methods 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- 238000010276 construction Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Warehouses Or Storage Devices (AREA)
Abstract
The invention discloses a method and a device for automatically synchronizing codes among Git warehouses, and a code synchronization technology. The scheme is provided for solving the problems that the code synchronization process is complex and error is easy to occur in the prior art. The method comprises the following steps: the step of configuring the Jenkins pipeline: configuring information of a source warehouse, information of each target warehouse, branches needing synchronization and corresponding tags; triggering a Jenkins pipeline: triggering the Jenkins pipeline to work as required; and, the step of executing the Jenkins pipeline: and pushing the specified codes to each target warehouse according to the configuration information. The method has the advantages that a code developer only needs to push the code written by the code developer to one target warehouse, the operation of synchronizing the code to other warehouses and the time of synchronizing are not needed to be considered, and the situation of other warehouses is not needed to be concerned. The repeated workload of project management personnel is greatly simplified. Avoiding various problems caused by manual pushing.
Description
Technical Field
The invention relates to a code synchronization technology, in particular to a method and a device for automatically synchronizing codes among Git warehouses.
Background
Typically, the code of an item needs to be synchronized into different warehouses in order for the code construction and release applications to take place in different environments. At present, each project group has own code warehouse service, and aiming at specific projects, each developer writes codes locally, develops tests and submits the codes to the code servers of the project group. If the code is to be synchronized to other warehouse services, it is pushed manually or by other tool manual operations. When the number of target warehouses to be synchronized is large, and branches to be synchronized of each target warehouse have respective requirements with tags, the conditions that synchronization is not timely, part of targets forget to synchronize, push confusion is caused, and the synchronization error rate is high are often caused. The target warehouse is very easy to be confused and has no method for unified management.
Where a repository refers to a Git code repository such as Github, gitLab, gitee, gitblit, etc. Branches refer to branches of the Git code warehouse.
Disclosure of Invention
The invention aims to provide a method and a device for automatically synchronizing codes among Git warehouses, which are used for solving the problems in the prior art.
The invention discloses a method for automatically synchronizing codes among Git warehouses, which comprises the following steps:
the step of configuring the Jenkins pipeline: configuring information of a source warehouse, information of each target warehouse, branches needing synchronization and corresponding tags;
triggering a Jenkins pipeline: triggering the Jenkins pipeline to work as required;
and, the step of executing the Jenkins pipeline: and pushing the specified codes to each target warehouse according to the configuration information.
The Tag is the version number of the branch.
The step of executing the Jenkins pipeline comprises the sub-steps of:
pushing the Jenkins pipeline to a specified Git server one by one;
the Git server pulls source codes in a source warehouse according to the configured Jenkins pipeline;
analyzing branches and corresponding tags which need to be synchronized in a current Git server;
acquiring the configuration of a target warehouse needing to be synchronized;
analyzing branches and corresponding tags which are configured for each target warehouse and need to be synchronized;
and pushing codes to each target warehouse according to the branches and the corresponding tags.
The information of the source warehouse and the target warehouse comprises: address, username, password.
If the target warehouse is configured with the pushing strategies of the branches and the tags independently, pushing the corresponding branches preferentially according to the pushing strategies; otherwise, all branches and corresponding tags of the source warehouse are pushed to the target warehouse by default.
In the step of triggering the Jenkins pipeline, the triggered node is triggered manually, or triggered by a timer, or triggered when any code is submitted to a source warehouse.
When the timer is triggered, the timer is preconfigured to be executed once or periodically; if the period is executed, the period length is used as a node by the period, or by the day, or by the hour.
When any code is submitted to the source repository, the Jenkins pipeline is triggered to work by its hook function call Jenkins pipeline's API port.
The manual trigger is that a specific person manually calls an API port of the Jenkins pipeline to trigger the Jenkins pipeline to work.
The invention discloses a device for automatically synchronizing codes among Git warehouses, which utilizes the method to synchronize the codes.
The method and the device for automatically synchronizing the codes among the Git warehouses have the advantages that a code developer only needs to push the codes written by the code developer to one target warehouse, the operation of synchronizing the codes to other warehouses and the time of synchronizing the codes are not needed to be considered, and the condition of other warehouses is not needed to be concerned. The repeated workload of project management personnel is greatly simplified. Avoiding various problems caused by manual pushing. The codes of the source warehouse need to be synchronized to the operation automation unified execution of different target warehouses, thereby being convenient for the operation and maintenance management of related personnel.
Drawings
FIG. 1 is a flow chart of a method for automatically synchronizing codes among Git warehouses according to the present invention.
Detailed Description
As shown in FIG. 1, the method for automatically synchronizing codes among Git warehouses combines the Jenkins pipeline technology, and provides a scheme capable of automatically pulling source warehouse codes through the Jenkins pipeline. The code is automatically synchronized into a plurality of different target warehouses, and branches and tags pushed by each target warehouse may each define a policy to push.
The generation of the Jenkins pipeline can be directly configured and generated on the Jenkins interface operation, and the Jenkins pipeline script of the synchronous logic is written. The known third-party system can also directly call the API of the Jenkins to automatically generate the Jenkins pipeline, and additional writing of Jenkins pipeline scripts is not needed. The Jenkins pipeline creation is performed in this embodiment using a known system.
The execution of the Jenkins pipeline is triggered by the system call Jenkins or the timer of the Jenkins pipeline is triggered to execute, so that the rule of autonomously defining the synchronous execution time of the code is achieved.
First, the Jenkins pipeline is configured to be created or modified:
a) Configuration warehouse information: configuring addresses, user names and passwords of a source warehouse and a target warehouse; multiple target warehouses may be configured, i.e., code of a source warehouse may be pushed into the configured multiple target warehouses.
b) Configuring a synchronous branch and a corresponding Tag: for a configured target warehouse, only synchronously appointed branches and corresponding tags of the warehouse can be set; the configuration mode can enumerate and list the needed branches and the corresponding tags, and can also adopt a regular expression for processing. Each target warehouse can independently set a pushing strategy of branches and corresponding tags, and if the target warehouse is not configured, all branches and corresponding tags of the source warehouse are pushed to the target warehouse by default.
When the Jenkins pipeline is triggered on demand, there are at least three triggering modes:
a) And (3) manual triggering: related personnel can click on the system to perform the task of calling the Jenkins API to execute the Jenkins pipeline synchronous code.
b) And (3) timing triggering: the timing configuration of the Jenkins pipeline automatic execution may be set, and each day, week, and hour may be set as nodes. It is also possible to configure a single execution or a periodic execution. The timer reaches the configured execution time point, and the Jenkins pipeline automatically runs the task of synchronizing codes without manual intervention, so that the aim of timing the synchronizing codes is fulfilled.
c) Triggering when code is submitted: when the developer pushes the code to the source code repository, the Jenkins API is called through the hook function of the Git repository. The Jenkins pipeline performs the task of synchronizing code. The purpose of real-time code synchronization is achieved.
The Jenkins pipeline analyzes and executes synchronous codes specifically as follows:
a) The source code is pulled.
b) And analyzing the target warehouse branches which are pre-configured and need to be pushed and the corresponding tags. The configuration information may specify a specific branch and a corresponding Tag, or may be processed by a regular expression.
By associating each remote branch of the configuration, push work is performed for each target warehouse.
The invention discloses a device for automatically synchronizing codes among Git warehouses, which performs code synchronization processing by using the method.
It will be apparent to those skilled in the art from this disclosure that various other changes and modifications can be made which are within the scope of the invention as defined in the appended claims.
Claims (10)
1. The method for automatically synchronizing codes among the Git warehouse is characterized by comprising the following steps of:
the step of configuring the Jenkins pipeline: configuring information of a source warehouse, information of each target warehouse, branches needing synchronization and corresponding tags;
triggering a Jenkins pipeline: triggering the Jenkins pipeline to work as required;
and, the step of executing the Jenkins pipeline: and pushing the specified codes to each target warehouse according to the configuration information.
2. A method for automatically synchronizing codes between Git warehouses according to claim 1, wherein said Tag is a version number of a branch.
3. A method of automatic synchronization of code between Git warehouses according to claim 1, wherein said step of executing a Jenkins pipeline comprises the sub-steps of:
pushing the Jenkins pipeline to a specified Git server one by one;
the Git server pulls source codes in a source warehouse according to the configured Jenkins pipeline;
analyzing branches and corresponding tags which need to be synchronized in a current Git server;
acquiring the configuration of a target warehouse needing to be synchronized;
analyzing branches and corresponding tags which are configured for each target warehouse and need to be synchronized;
and pushing codes to each target warehouse according to the branches and the corresponding tags.
4. A method of automatic synchronization of code between Git repositories as in claim 1, wherein the information of both the source repository and the target repository comprises: address, username, password.
5. The method for automatically synchronizing codes among Git warehouses according to claim 1, wherein if the target warehouse is configured with the pushing strategies of branches and tags independently, pushing the corresponding branches preferentially according to the pushing strategies; otherwise, all branches and corresponding tags of the source warehouse are pushed to the target warehouse by default.
6. The method of claim 1, wherein in the step of triggering the Jenkins pipeline, the triggered node is triggered manually, or by a timer, or when any code is submitted to the source repository.
7. A method for automatically synchronizing codes between Git warehouses according to claim 6, wherein the timer is pre-configured to be a single execution or a periodic execution when triggered by a timer; if the period is executed, the period length is used as a node by the period, or by the day, or by the hour.
8. The method of automatic synchronization of code between Git warehouses of claim 6, wherein when any code is submitted to the source warehouse, the Jenkins pipeline is triggered to operate by a hook function of the source warehouse calling an API port of the Jenkins pipeline.
9. The method for automatically synchronizing codes among Git warehouses according to claim 6, wherein the manual trigger is a specific person manually calling an API port of the Jenkins pipeline to trigger the Jenkins pipeline to work.
10. An apparatus for automatic synchronization of codes between Git warehouses, characterized in that the code synchronization is performed by means of a method as claimed in any of claims 1-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211217730.8A CN117827265A (en) | 2022-09-29 | 2022-09-29 | Method and device for automatically synchronizing codes among Git warehouse |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211217730.8A CN117827265A (en) | 2022-09-29 | 2022-09-29 | Method and device for automatically synchronizing codes among Git warehouse |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117827265A true CN117827265A (en) | 2024-04-05 |
Family
ID=90512318
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211217730.8A Pending CN117827265A (en) | 2022-09-29 | 2022-09-29 | Method and device for automatically synchronizing codes among Git warehouse |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117827265A (en) |
-
2022
- 2022-09-29 CN CN202211217730.8A patent/CN117827265A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109815028B (en) | System, method, apparatus and computer storage medium for data synchronization | |
AU2017409830B2 (en) | Multi-task scheduling method and system, application server and computer-readable storage medium | |
US20030226138A1 (en) | Installation of application software through a network from a source computer system on to a target computer system | |
CN113228020B (en) | Scheduling robots for robot process automation | |
EP3617961A1 (en) | Intelligent adaptor service in unified automation platforms for robotic process automation | |
CN103645909A (en) | Handling method and device for timed task | |
JP2018129020A (en) | Method and apparatus for controlling and managing industrial processes using industrial internet operating system | |
CN108984272A (en) | The control method and device of OpenStack cloud computing management platform | |
CN104216785A (en) | Common policy task system and implementing method thereof | |
CN111240935B (en) | Automatic intelligent operation and maintenance system and operation and maintenance method | |
US9921882B2 (en) | Information processing system, deployment method, processing device, and deployment device | |
CN103885364A (en) | Method for achieving dynamic delay call of control logic through planned queue | |
CN112286664B (en) | Task scheduling method, device, computer equipment and readable storage medium | |
CN105787300B (en) | Method and system for controlling use of software | |
CN110569113A (en) | Method and system for scheduling distributed tasks and computer readable storage medium | |
CN110730197B (en) | Service discovery method and system | |
CN117827265A (en) | Method and device for automatically synchronizing codes among Git warehouse | |
US9207928B2 (en) | Computer-readable medium, apparatus, and methods of automatic capability installation | |
US8301273B2 (en) | Method for providing functions in an industrial automation system, control program and industrial automation system | |
CN112350862A (en) | Monitoring alarm and fault self-healing system | |
US10728323B2 (en) | Method and apparatus for operating infrastructure layer in cloud computing architecture | |
CN105577310A (en) | Synchronization method for task partitioning and communication scheduling in time trigger network | |
CN110990035B (en) | Chain type software upgrading method based on Git | |
CN105573841B (en) | A method of the control timer based on non-relational database executes | |
TWI826182B (en) | Cloud platform management system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |