A Jenkins job migration method and migration device

Through the automated jenkins job migration method, efficient and accurate migration from maven or freestyle job to pipeline job is achieved based on the configuration file and label correspondence, solving the problem of incomplete manual migration in the existing technology.

CN114741356BActive Publication Date: 2025-08-15BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210415140.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-20
Publication Date
2025-08-15
Estimated Expiration
2042-04-20

AI Technical Summary

Technical Problem

In the existing technology, most of the migration methods of jenkins jobs are manual migration, and it is impossible to ensure that all jobs have been migrated, and the migration process is prone to errors and cannot meet the needs of the devops cloud platform.

Method used

By obtaining the configuration file of the job to be migrated, determining its type number, creating the migrated pipeline job, and writing a configuration file template based on the corresponding relationship between the configuration file and the tag, to achieve automated migration of the job.

Benefits of technology

It realizes efficient and accurate migration of jenkins jobs to the devops cloud platform, avoids manual migration errors and ensures complete migration of all jobs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114741356B_ABST
    Figure CN114741356B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of distributed technology and discloses a Jenkins job migration method and migration device, wherein the method comprises: obtaining a job to be migrated; determining a type number corresponding to the job to be migrated based on a configuration file of the job to be migrated; creating a migrated pipeline job based on the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a configuration file template; and writing the configuration file template based on the configuration file of the job to be migrated and a label correspondence between the configuration file of the job to be migrated and the configuration file of the migrated pipeline job, thereby obtaining a migrated pipeline job. The present invention can efficiently and accurately complete the migration of Jenkins jobs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed technology, and in particular to a Jenkins job migration method and migration device. Background Art

[0002] Jenkins is an open-source Java-based continuous integration tool designed to provide an open and easy-to-use platform for continuous integration of software projects. Existing technologies mostly use native Jenkins, where Jenkins jobs are typically created using Maven or Freestyle projects. With the development of DevOps and cloud computing technologies, DevOps' automated release capabilities are also moving to the cloud. Therefore, it is now necessary to migrate existing Maven or Freestyle jobs to the DevOps cloud platform to form pipeline jobs.

[0003] However, most current migration methods are manual migration, which cannot guarantee that all Jenkins jobs are migrated, and the migration process is prone to errors. Therefore, there is an urgent need for a Jenkins job migration method that can complete the migration of Jenkins jobs efficiently and accurately. Summary of the Invention

[0004] The embodiment of the present invention provides a Jenkins job migration method and migration device for efficiently and accurately completing the migration of Jenkins jobs, wherein the method includes:

[0005] Get the job to be migrated;

[0006] Determine the type number corresponding to the job to be migrated according to the configuration file of the job to be migrated;

[0007] Creating a migrated pipeline job according to the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a template of a configuration file;

[0008] According to the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job after migration, a template of the configuration file is compiled to obtain a migrated pipeline job.

[0009] Preferably, obtaining the job to be migrated further includes:

[0010] According to the address identifier of Jenkins, determine the view corresponding to the Jenkins;

[0011] The job to be migrated is determined based on the job corresponding to the view.

[0012] Preferably, after determining the job to be migrated according to the job corresponding to the view, the step further includes:

[0013] The configuration file of the job to be migrated is stored in the form of a three-level directory, wherein the first-level directory is the address identifier of Jenkins, the second-level directory is the view corresponding to the Jenkins, and the third-level directory is the configuration file of the job to be migrated corresponding to the view.

[0014] Preferably, determining the type number corresponding to the job to be migrated according to the configuration file of the job to be migrated further includes:

[0015] Reading an instruction corresponding to a type identification tag in a configuration file of the job to be migrated to obtain a type identification corresponding to the job to be migrated, wherein the type identification is used to indicate the type of the job to be migrated;

[0016] According to the type identifier, the type number corresponding to the job to be migrated is determined.

[0017] Preferably, before determining the type number corresponding to the job to be migrated based on the configuration file of the job to be migrated, the method further includes:

[0018] A correspondence between a type identifier and a type number is established, where the type number is used to represent the type corresponding to the migrated pipeline job.

[0019] Preferably, the tag correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job records:

[0020] The configuration file of the job to be migrated has multiple different first tags, each of which corresponds to a different instruction; the configuration file of the pipeline job has multiple different second tags, wherein the multiple different first tags correspond one-to-one to the multiple different second tags respectively;

[0021] Accordingly, the step of writing a template for the configuration file based on the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job to obtain the migrated pipeline job further includes:

[0022] Traverse all first tags in the configuration file of the job to be migrated and determine the instruction corresponding to the first tag;

[0023] The instruction corresponding to the first tag is written into a second tag in a template of the configuration file of the pipeline job, which has a one-to-one correspondence with the first tag, to obtain a migrated pipeline job.

[0024] An embodiment of the present invention further provides a Jenkins job migration device, comprising:

[0025] Acquisition module, used to obtain the job to be migrated;

[0026] A determination module, configured to determine a type number corresponding to the job to be migrated based on a configuration file of the job to be migrated;

[0027] A creation module, configured to create a migrated pipeline job according to the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a template of a configuration file;

[0028] The migration completion module is used to write a template of the configuration file according to the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job, so as to obtain a pipeline job that has completed migration.

[0029] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned Jenkins job migration methods when executing the computer program.

[0030] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the computer program implements any of the above-mentioned Jenkins job migration methods.

[0031] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements any of the above-mentioned Jenkins job migration methods.

[0032] Compared to existing solutions, the method described in this embodiment of the present invention can migrate all pending jobs into pipeline jobs. Based on the configuration files and tag mappings of the pending jobs, the tag instructions in the pending job configuration files are rewritten as tag instructions in the template of the pipeline job configuration files, resulting in a fully migrated pipeline job. Compared to manual migration, this migration method is less prone to errors and achieves efficient and complete migration. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0034] Figure 1 A schematic diagram of a Jenkins job migration method provided in an embodiment of the present invention;

[0035] Figure 2 A schematic diagram of a process for obtaining a job to be migrated provided in an embodiment of the present invention;

[0036] Figure 3 A schematic diagram of a process for determining the type number corresponding to the job to be migrated provided in an embodiment of the present invention;

[0037] Figure 4 A schematic diagram of a process for obtaining a migrated pipeline job based on the configuration file and label correspondence of the job to be migrated, provided in an embodiment of the present invention;

[0038] Figure 5 A schematic diagram of the module structure of a Jenkins job migration device provided in an embodiment of the present invention;

[0039] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention.

[0040] Description of the accompanying symbols:

[0041] 100. Get module;

[0042] 200. Determine module;

[0043] 300. Create module;

[0044] 400. Migration completed module;

[0045] 602. Computer equipment;

[0046] 604, processor;

[0047] 606, memory;

[0048] 608, driving mechanism;

[0049] 610, input / output module;

[0050] 612. Input devices;

[0051] 614. Output device;

[0052] 616. Presentation equipment;

[0053] 618. Graphical User Interface;

[0054] 620, network interface;

[0055] 622, communication link;

[0056] 624. Communication bus. DETAILED DESCRIPTION

[0057] To make the purpose, technical solutions and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0058] Existing technologies mostly use native Jenkins, where Jenkins jobs are typically created using Maven projects or freestyle projects. However, with the development of DevOps and cloud computing, DevOps' automated release capabilities are also moving to the cloud. Therefore, it's necessary to migrate existing Maven or freestyle jobs to the DevOps cloud platform to form pipeline jobs.

[0059] However, most current migration methods are manual migration, which cannot guarantee that all Jenkins jobs are migrated, and the migration process is prone to errors.

[0060] In order to solve the above problems, this embodiment provides a Jenkins job migration method. Figure 1This is a flowchart of a Jenkins job migration method provided in the embodiments herein. While this specification provides the method steps described in the embodiments or flowcharts, more or fewer steps may be included based on routine or uninventive work. The order of steps listed in the embodiments is merely one of many possible execution sequences and does not represent the only execution order. In actual systems or device products, the methods described in the embodiments or figures may be executed sequentially or in parallel.

[0061] It should be noted that the terms "first," "second," and the like in the specification and claims herein and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or devices.

[0062] Reference Figure 1 This article provides a Jenkins job migration method, including:

[0063] S101: Get the job to be migrated;

[0064] S102: Determine the type number corresponding to the job to be migrated according to the configuration file of the job to be migrated;

[0065] S103: Creating a migrated pipeline job according to the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a template of a configuration file;

[0066] S104: According to the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job after migration, a template of the configuration file is compiled to obtain a migrated pipeline job.

[0067] There are many jobs on the Jenkins server. Most of the jobs to be migrated are in Maven project style, and a small number are in freestyle style. The jobs to be migrated can be divided into Maven jobs and freestyle jobs according to the project style. For the jobs to be migrated, they need to be migrated to pipeline style, that is, migrate Maven jobs and freestyle jobs into pipeline jobs to meet the requirements of DevOps cloud management.

[0068] During the migration process, you need to migrate the contents of the Maven and Freestyle job configuration files to the pipeline job configuration files. Jobs to be migrated are categorized into different types based on their functionality, and each type of job corresponds to a different type of pipeline job. Because multiple jobs to be migrated may perform the same functionality, these jobs are considered to be of the same type and correspond to the same type of pipeline job.

[0069] Each type of pipeline job includes its corresponding configuration file template. The configuration file template records the full set of tags in the corresponding pipeline job's configuration file. Of course, the specific content of the tags recorded in the configuration files of different templates is also different. However, since they are configuration file templates, the tags do not contain specific instructions.

[0070] For example, a Maven job A implements environmental testing, and its corresponding pipeline job A' also implements the environmental testing function. The configuration file template A'.xml of pipeline job A' records all the tags required to implement the environmental testing function. However, since A'.xml is only a configuration file template, there are no specific instructions in the tags.

[0071] The type number described in this article represents the type of pipeline job after migration. You can determine the type of pipeline job corresponding to each job to be migrated by determining the type number corresponding to the job to be migrated. This article determines the type number corresponding to the job to be migrated based on the configuration file of the job to be migrated.

[0072] Because different type numbers correspond to different functions, for example, a job to be migrated that implements environmental testing is assigned type number "1" based on its configuration file A.xml. A migrated pipeline job is created with type number "1." This migrated pipeline job also implements environmental testing and includes the configuration file template. This means that the created migrated pipeline job is not a fully migrated pipeline job. The tags in the pipeline job's configuration file template do not contain specific instructions and cannot implement the relevant functions.

[0073] In order to further migrate and complete the pipeline job, it is necessary to write a template for the configuration file. The template for writing the configuration file mentioned here mainly refers to writing specific instructions in the tags of the configuration file template. When writing specific instructions, it is necessary to base it on the configuration file of the job to be migrated, as well as the tag correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job. Since the tags in the configuration file of the job to be migrated are written in Maven format or freestyle format, which is somewhat different from the pipeline format, the tag correspondence mainly establishes a connection between the tags with the same meaning in the configuration file of the job to be migrated and the configuration file of the pipeline job. According to the tag correspondence, the instructions of the tags in the configuration file of the job to be migrated can be written into the tags of the corresponding configuration file of the pipeline job.

[0074] For example, the configuration file of Maven job A includes a tag for shell deployment, specifically<hudson.tasks.Shell> <command> , and the tag for shell deployment in the template A'.xml of the pipeline job A' configuration file is stage('Deploy'). It is necessary to establish a corresponding relationship between these two tags. According to this tag correspondence,<hudson.tasks.Shell> <command> The instructions for this tag are written to the stage ('Deploy') of the A'.xml template in the pipeline job A' configuration file. By following this method to write the configuration file template, you can create a fully migrated pipeline job.

[0075] Using the method described in this article, all jobs to be migrated can be converted into pipeline jobs. Based on the job configuration files and their tag mappings, the tag instructions in the job configuration files are rewritten as the tag instructions in the pipeline job configuration file template, resulting in a fully migrated pipeline job. Compared to manual migration, this migration method is less error-prone and achieves efficient and complete migration.

[0076] In the examples herein, reference Figure 2 , the obtaining of the job to be migrated further includes:

[0077] S201: Determine the view corresponding to the Jenkins according to the address identifier of the Jenkins;

[0078] S202: Determine the job to be migrated according to the job corresponding to the view.

[0079] Jenkins has multiple versions, each with different storage addresses. Even the same version of Jenkins may have multiple storage addresses. In this article, we use the Jenkins storage address (specifically, the IP address) as the address identifier. For Jenkins with different address identifiers, each address identifier corresponds to multiple views under Jenkins, and each view contains multiple jobs to be migrated. By first searching the storage address and then the view, we can retrieve all jobs to be migrated without duplication or omission.

[0080] In the embodiment of this document, after determining the job to be migrated according to the job corresponding to the view, the following steps are further performed:

[0081] The configuration file of the job to be migrated is stored in the form of a three-level directory, wherein the first-level directory is the address identifier of Jenkins, the second-level directory is the view corresponding to the Jenkins, and the third-level directory is the configuration file of the job to be migrated corresponding to the view.

[0082] To facilitate modification of the job configuration files to be migrated, store them in a three-level directory. The first-level directory is the Jenkins address identifier (in this article, the Jenkins address identifier is the Jenkins storage address), the second-level directory is the view directory, and the third-level directory is the configuration file. For example, the job configuration file A.xml to be migrated can be stored in the form of IP1-view1-A.xml. It is important to note that when storing the job configuration files in a three-level directory, in order to distinguish different jobs to be migrated, the configuration files can be named according to the name of the job to be migrated.

[0083] In the examples herein, reference Figure 3 The step of determining the type number corresponding to the job to be migrated according to the configuration file of the job to be migrated further includes:

[0084] S301: Reading an instruction corresponding to a type identification tag in a configuration file of the job to be migrated, and obtaining a type identification corresponding to the job to be migrated, wherein the type identification is used to indicate the type of the job to be migrated;

[0085] S302: Determine the type number corresponding to the job to be migrated according to the type identifier.

[0086] For jobs to be migrated, the instruction corresponding to the type identifier tag in the configuration file records the type identifier of the job to be migrated. As mentioned above, jobs to be migrated are divided into different types according to their functions. In other words, jobs to be migrated with different functions have different type identifiers. However, because multiple jobs to be migrated may implement the same function, these jobs have the same type identifier.

[0087] In the embodiment of this article, for example, the type identification tag can be <description>< / description> Tags can also be <assignednode>< / assignednode> The two tags are a description class tag and an allocation node class tag. Suppose there are two jobs to be migrated. One job's configuration file contains the description class tag directive "environmental test," while the other job's configuration file contains the node class tag directive "environmental test." This indicates that both jobs perform environmental testing. Therefore, since these two jobs are of the same type, they will have the same type identifier: environmental test.

[0088] Since the type identifiers are the same, the type numbers corresponding to the jobs to be migrated determined according to the type identifiers are also the same, and the type numbers corresponding to the two jobs to be migrated are both "1".

[0089] In the embodiment of this document, before determining the type number corresponding to the job to be migrated according to the configuration file of the job to be migrated, the following steps are further included:

[0090] A correspondence between a type identifier and a type number is established, where the type number is used to represent the type corresponding to the migrated pipeline job.

[0091] Since the type number is used to represent the type of the pipeline job after migration, the type identifiers of the two jobs to be migrated are both environment test identifiers. The type number corresponding to the environment test identifier is "1", so the pipeline job types corresponding to the two jobs to be migrated are the same.

[0092] It can be understood from the above steps that the type identifier corresponding to the job to be migrated is obtained through the instruction corresponding to the type identifier tag in the configuration file of the job to be migrated, and the pipeline job corresponding to the job to be migrated is obtained according to the correspondence between the type identifier and the type number.

[0093] In this embodiment, the tag correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job records:

[0094] The configuration file of the job to be migrated has multiple different first tags, each different first tag corresponds to a different instruction, and the configuration file of the pipeline job has multiple different second tags, wherein the multiple different first tags correspond one-to-one to the multiple different second tags respectively.

[0095] Each first tag corresponds to a second tag. The first tag and the corresponding second tag are tags that issue the same instruction. Therefore, the instruction of the first tag and the instruction of the corresponding second tag are the same. For multiple different first tags, each first tag corresponds to a different instruction.

[0096] For example, the configuration file of the job to be migrated includes a first tag for shell deployment, specifically<hudson.tasks.Shell> <command> , and its one-to-one correspondence is the second tag stage ('Deploy') for shell deployment in the pipeline job configuration file.

[0097] Reference Figure 4 Accordingly, the step of writing a template for the configuration file based on the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job to obtain the migrated pipeline job further includes:

[0098] S401: Traverse all first tags in the configuration file of the job to be migrated and determine the instructions corresponding to the first tags;

[0099] S402: Writing the instruction corresponding to the first tag into the second tag corresponding to the first tag in the template of the configuration file of the pipeline job to obtain a migrated pipeline job.

[0100] In the description of S101 to S104 above, it has been pointed out that there is no specific instruction in the tag of the configuration file template. That is to say, the instruction corresponding to the first tag needs to be written into the second tag in the configuration file template that corresponds to the first tag one-to-one according to the tag correspondence.<hudson.tasks.Shell> <command> Write the instructions in stage('Deploy'). After all the instructions in the second tag in the configuration file template are written, the migrated pipeline job can be obtained.

[0101] Through the one-to-one correspondence between the first tag and the second tag, all the instructions of the first tag in the configuration file of the job to be migrated can be completely migrated to the second tag in the configuration file of the pipeline job. Therefore, this article breaks away from the existing method of manually migrating jobs and can migrate jobs efficiently, quickly, and with high accuracy.

[0102] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0103] The present invention also provides a Jenkins job migration device, as described in the following embodiments. Since the principle of the device to solve the problem is similar to that of a Jenkins job migration method, the implementation of the device can refer to the implementation of a Jenkins job migration method, and the repeated parts will not be repeated.

[0104] Reference Figure 5The embodiment of this invention provides a Jenkins job migration device, which includes: an acquisition module 100, a determination module 200, a creation module 300, and a migration completion module 400.

[0105] The acquisition module 100 is used to obtain the job to be migrated;

[0106] A determination module 200 is configured to determine a type number corresponding to the job to be migrated based on a configuration file of the job to be migrated;

[0107] A creation module 300 is configured to create a migrated pipeline job according to the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a configuration file template;

[0108] The migration completion module 400 is configured to compile a template of the configuration file according to the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job, and obtain a pipeline job that has completed migration.

[0109] Compared to existing solutions, the method described in this embodiment of the present invention can migrate all pending jobs into pipeline jobs. Based on the configuration files and tag mappings of the pending jobs, the tag instructions in the pending job configuration files are rewritten as tag instructions in the template of the pipeline job configuration files, resulting in a fully migrated pipeline job. Compared to manual migration, this migration method is less prone to errors and achieves efficient and complete migration.

[0110] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned Jenkins job migration methods when executing the computer program.

[0111] Reference Figure 6As shown, the above-described Jenkins job migration method is executed on a computer device 602. The computer device 602 may include one or more processors 604, such as one or more central processing units (CPUs) or graphics processing units (GPUs). Each processing unit may implement one or more hardware threads. The computer device 602 may also include any memory 606 for storing any type of information, such as code, settings, data, etc. In one embodiment, the memory 606 may contain a computer program executable on the processor 604. When executed by the processor 604, the computer program may execute instructions according to the above-described method. For example, and without limitation, the memory 606 may include any one or more combinations of the following: any type of RAM, any type of ROM, a flash memory device, a hard disk, an optical disk, etc. More generally, any memory may use any technology to store information. Furthermore, any memory may provide volatile or non-volatile retention of information. Furthermore, any memory may represent a fixed or removable component of the computer device 602. In one embodiment, when the processor 604 executes the associated instructions stored in any memory or combination of memories, the computer device 602 can perform any operation of the associated instructions. The computer device 602 also includes one or more drive mechanisms 608 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.

[0112] The computer device 602 may also include an input / output module 610 (I / O) for receiving various inputs (via input devices 612) and for providing various outputs (via output devices 614). A specific output mechanism may include a presentation device 616 and an associated graphical user interface 618 (GUI). In other embodiments, the input / output module 610 (I / O), input devices 612, and output devices 614 may not be included, and the computer device 602 may simply be a computer device in a network. The computer device 602 may also include one or more network interfaces 620 for exchanging data with other devices via one or more communication links 622. One or more communication buses 624 couple the components described above together.

[0113] The communication link 622 may be implemented in any manner, for example, via a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 622 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.

[0114] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program implements any of the above-mentioned Jenkins job migration methods when executed by a processor.

[0115] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements any of the above-mentioned Jenkins job migration methods.

[0116] Compared to existing solutions, the method described in this embodiment of the present invention can migrate all pending jobs into pipeline jobs. Based on the configuration files and tag mappings of the pending jobs, the tag instructions in the pending job configuration files are rewritten as tag instructions in the template of the pipeline job configuration files, resulting in a fully migrated pipeline job. Compared to manual migration, this migration method is less prone to errors and achieves efficient and complete migration.

[0117] It should be understood that in the various embodiments of this document, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this document.

[0118] It should also be understood that in the embodiments herein, the term "and / or" merely describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" could represent: A alone, A and B simultaneously, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the associated objects.

[0119] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0120] To clearly illustrate the interchangeability of hardware and software, the above descriptions have generally described the components and steps of each example by function. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Professionals may use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this document.

[0121] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0122] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0123] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0124] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0125] In the several embodiments provided herein, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices, or units, or can be an electrical, mechanical, or other form of connection.

[0126] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments herein.

[0127] In addition, the functional units in the various embodiments herein may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0128] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.

[0129] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A Jenkins job migration method, characterized in that: include: Get the job to be migrated; Reading an instruction corresponding to a type identification tag in a configuration file of the job to be migrated to obtain a type identification corresponding to the job to be migrated, wherein the type identification is used to represent the type of the job to be migrated, and jobs to be migrated with different functions have different type identifications. Determine the type number corresponding to the job to be migrated according to the type identifier; Creating a migrated pipeline job according to the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a template of a configuration file; According to the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job after migration, a template of the configuration file is compiled to obtain a migrated pipeline job.

2. The Jenkins job migration method according to claim 1, wherein: The obtaining of the job to be migrated further includes: According to the address identifier of Jenkins, determine the view corresponding to the Jenkins; The job to be migrated is determined based on the job corresponding to the view.

3. The Jenkins job migration method according to claim 2, wherein: After determining the job to be migrated according to the job corresponding to the view, the following steps are further included: The configuration file of the job to be migrated is stored in the form of a three-level directory, wherein the first-level directory is the address identifier of Jenkins, the second-level directory is the view corresponding to the Jenkins, and the third-level directory is the configuration file of the job to be migrated corresponding to the view.

4. The Jenkins job migration method according to claim 3, wherein: Before determining the type number corresponding to the job to be migrated according to the configuration file of the job to be migrated, the method further includes: A correspondence between a type identifier and a type number is established, where the type number is used to represent the type corresponding to the migrated pipeline job.

5. The Jenkins job migration method according to claim 1, wherein: The label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job records: The configuration file of the job to be migrated has multiple different first tags, each of which corresponds to a different instruction; the configuration file of the pipeline job has multiple different second tags, wherein the multiple different first tags correspond one-to-one to the multiple different second tags respectively; Accordingly, the step of writing a template for the configuration file based on the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job to obtain the migrated pipeline job further includes: Traverse all first tags in the configuration file of the job to be migrated and determine the instruction corresponding to the first tag; The instruction corresponding to the first tag is written into a second tag in a template of the configuration file of the pipeline job, which has a one-to-one correspondence with the first tag, to obtain a migrated pipeline job.

6. A Jenkins job migration device, characterized in that: include: Acquisition module, used to obtain the job to be migrated; a determination module configured to read an instruction corresponding to a type identification tag in a configuration file of the job to be migrated, and obtain a type identification corresponding to the job to be migrated, wherein the type identification is used to represent the type of the job to be migrated, and jobs to be migrated with different functions have different type identifications; Determine the type number corresponding to the job to be migrated according to the type identifier; A creation module, configured to create a migrated pipeline job according to the type number corresponding to the job to be migrated, wherein the migrated pipeline job includes a template of a configuration file; The migration completion module is used to write a template of the configuration file according to the configuration file of the job to be migrated and the label correspondence between the configuration file of the job to be migrated and the configuration file of the pipeline job, so as to obtain a pipeline job that has completed migration.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

9. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Code migration method, equipment and storage medium

    CN111008037A