CN117707547A - Method for analyzing quotation relation among java items - Google Patents
Method for analyzing quotation relation among java items Download PDFInfo
- Publication number
- CN117707547A CN117707547A CN202410161497.9A CN202410161497A CN117707547A CN 117707547 A CN117707547 A CN 117707547A CN 202410161497 A CN202410161497 A CN 202410161497A CN 117707547 A CN117707547 A CN 117707547A
- Authority
- CN
- China
- Prior art keywords
- java
- item
- character string
- marking
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 23
- 239000011148 porous material Substances 0.000 claims abstract description 11
- 238000012856 packing Methods 0.000 claims abstract description 5
- 125000004122 cyclic group Chemical group 0.000 claims description 2
- 238000004806 packaging method and process Methods 0.000 claims description 2
- 238000011835 investigation Methods 0.000 abstract description 4
- 230000011218 segmentation Effects 0.000 abstract description 2
- 238000010276 construction Methods 0.000 description 3
- 230000006978 adaptation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 238000006467 substitution reaction 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/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a method for analyzing a quotation relation between java items, which comprises the steps of constructing java items for realizing services based on jenkins' pipelines; copying a python script formed by packing source codes of java items into a jenkins workspace; reading a pore file of a java item through a python script, and extracting data of an item referenced by the java item; obtaining a directory path of a jenkins workspace; dividing the character string of the directory path into a plurality of sub-character strings; and marking the last substring of the character string segmentation of the directory path as the name of the current service, and marking the data of the item referenced by the extracted java item as the name of the service referenced by the current service. According to the invention, all the services referenced by the current service are acquired based on jenkins, so that project personnel can understand the relationship between the services more quickly, and the problem investigation time is reduced.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method for analyzing a quotation relationship among java items.
Background
Micro-services are a software architecture model in which an application is broken down into small, autonomous services, each of which is in turn implemented by a java item. Each service has independent functions and responsibilities. Each service can be independently developed, tested, deployed and expanded, thereby improving maintainability, expandability and flexibility of the application program. The call relationship between services in the micro-services is realized through a registry, but other project personnel except the developer do not know the dependency relationship between services. In short, a service a is called by one Api, but the service B is down (the service a is not known to call the service B at this time), and the project personnel can only check all the services one by one until the down service B is found, and the problem can not be found and solved. If the service A is directly known to depend on the service B, namely, the reference relation between two corresponding java items of the service, the problem checking time is greatly reduced.
Therefore, the invention provides a method for analyzing the quotation relation among java items, which at least solves the technical problems.
Disclosure of Invention
Aiming at the problems, the invention provides a method for analyzing the quotation relationship among java items, which is used for acquiring all services quoted by the current service based on jenkins, so that project personnel can understand the relationship among the services more quickly, and the problem investigation time is reduced.
In order to achieve the above purpose, the technical scheme adopted by the invention is as follows:
a method for analyzing the quotation relation between java items comprises the following steps:
step 1, constructing java items for realizing services based on jenkins pipelines;
step 2, copying a python script formed by packing source codes of java items into a jenkins working space;
step 3, reading a pore file of the java item through the python script, and extracting data of the item referenced by the java item;
step 4, acquiring a directory path of the jenkins working space;
step 5, dividing the character string of the directory path into a plurality of sub character strings;
and 6, marking the last sub-string segmented in the step 5 as the name of the current service, and marking the data extracted in the step 2 as the name of the service referenced by the current service.
Further, step 1 includes: step 11, pulling source codes of java items from a Git warehouse; and step 12, packaging the source code into a python script, and waiting for the execution of the python script.
Further, in step 2, the jenkins workspace is the last layer directory of the task for constructing the java item, and the pore file is located in the last layer directory of the task for constructing the java item.
Further, in step 2, the name of the task for constructing the java item is set as the name of the java item.
Further, step 3 includes: step 31, reading configuration information of the pom file as a character string by a python script writing file reading method; and 32, acquiring coordinate information defining a unique identifier of the java item from the character string, and extracting data of the item referenced by the java item from the first coordinate information.
Further, in step 32, the regular expression is used to obtain coordinate information defining the unique identifier of the java item from the character string.
Further, in step 32, a regular expression is used to extract data of the item referenced by the java item from the first coordinate information.
Further, step 5 includes: step 51, defining an empty character string, namely a marked character string, defining an empty list and namely a marked list; step 52, using the forward slash symbol as a keyword for cyclic traversal to circularly traverse the character string of the directory path; step 53, when the traversed element is not a forward slash symbol, adding the current element to the tail of the marking character string, when the traversed element is a forward slash symbol, skipping over the current element and judging the length of the marking character string, when the length of the marking character string is not 0, adding the current marking character string to the marking list, and resetting the marking character string to be empty; step 54, repeating step 53 until the character string of the directory path is segmented, and marking all sub-character strings after the character string of the directory path is segmented in the list.
Further, the method further comprises the following steps: and 7, defining two empty lists, namely a master list and a slave list, respectively, adding the last sub-character string segmented in the step 5 into the master list, adding the data extracted in the step 2 into the slave list, wherein the master list contains the names of the current service, and the slave list contains the names of all the services referenced by the current service.
Compared with the prior art, the invention has the following beneficial effects:
according to the invention, all the services referenced by the current service are acquired based on jenkins, so that project personnel can understand the relationship between the services more quickly, and the problem investigation time is reduced. The invention combines the working space of jenkins, can be applied to any java item, has strong portability, does not need to be adapted, and can be realized by executing the python script of the java item in a jenkins pipeline.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
Term interpretation:
jenkins: is an open source software project and is a continuous integration tool based on Java development.
The present invention will be described in further detail with reference to the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in FIG. 1, the method for analyzing the quotation relationship among java items provided by the invention comprises the following steps:
step 1, constructing java items for realizing services based on jenkins pipelines;
step 2, copying a python script formed by packing source codes of java items into a jenkins working space;
step 3, reading a pore file of the java item through the python script, and extracting data of the item referenced by the java item;
step 4, acquiring a directory path of the jenkins working space;
step 5, dividing the character string of the directory path into a plurality of sub character strings;
and 6, marking the last sub-string segmented in the step 5 as the name of the current service, and marking the data extracted in the step 2 as the name of the service referenced by the current service.
According to the invention, all the services referenced by the current service are acquired based on jenkins, so that project personnel can understand the relationship between the services more quickly, and the problem investigation time is reduced.
The jenkins pipeline construction implementation service java item can customize the construction steps of the java item.
In some embodiments, the constructing the java item includes: pulling source code of a java item from a Git repository; the source code is packaged into a python script, awaiting execution of the python script.
The python script is typically placed in a fixed location in a directory on the server, which is not specified and can be arbitrarily agreed upon. When jenkins pipeline builds items, jenkins automatically generates a catalog, but the task for building each java item is a unique catalog, the name of the task is set as the current service name, so the name of the last layer of the task catalog is the name of the current service, namely, jenkins working space is the last layer of the task catalog. Since the pon file of the java item is placed in the final layer of the task directory, i.e., jenkins workspace, the python script formed by packing the source code is copied to the jenkins workspace so that the python script and the pon file are in the same directory.
Because the python script and the pom file are in the same catalog, the pom file can be directly read through the python script, and the data of the item referenced by the java item can be extracted.
In some embodiments, reading configuration information of the pore file as a character string by using a python script writing file reading method readline; coordinate information defining a unique identifier of a java item is obtained from the character string, and data of the item referenced by the java item is extracted from the first coordinate information. The pore file is an XML file, is one of core files of the project, and describes basic information, dependency items, construction, release and other information of the project. Wherein the coordinate information defining the unique identifier of the java item is a string beginning with an artifactId and ending with an artifactId, the item referenced by the pore file exists in the coordinate information defining the unique identifier of the java item, for example, the name of one referenced item is named as sample-app, and its corresponding coordinate information in the pore file is < artifactId > sample-app < artifactId >, so that the name of the item referenced by the current java item is obtained by extracting the data sample-app between the two artifactids, and the name of each service is the same as the name of the corresponding java item, for which the name of the service referenced by the current service can be obtained. Specifically, all the coordinate information is obtained from the character string through a regular expression "</artifactId > < artifactId > $", and then data of the item referenced by the java item is extracted through the regular expression. The invention combines the working space of jenkins, can use the method in any java project, has strong portability, does not need to make any adaptation, and can obtain the name of the service referenced by the current service by adding a command to execute the python script in the jenkins pipeline.
The name of the java item cannot be obtained after the java item is executed, and the name is also the name of the corresponding service, and the obtaining can be achieved by obtaining the directory path of the jenkins working space, namely the last layer directory of the task of the java item, specifically by writing and executing shell command pwd; and then, acquiring the task name, namely the corresponding java item and service name by analyzing the directory path of the jenkins working space, and specifically, extracting the task name by character string segmentation of the directory path.
In some embodiments, the dividing the string of the directory path into a plurality of substrings specifically includes: defining an empty character string, marking the character string as a marking character string, and defining an empty list, marking the character string as a marking list; the forward slash symbol "/" is used as a character string of a keyword circulation traversing directory path, and "/" is a standard path separator used in an operating system and is used for separating a hierarchical structure of directory and file names; when the traversed element is not the forward slash symbol "/", adding the current element to the tail part of the marking character string, when the traversed element is the forward slash symbol "/", skipping the current element and judging the length of the marking character string, when the length of the marking character string is not 0, adding the current marking character string to the marking list, and resetting the marking character string to be empty; and (5) traversing the steps until the character string of the directory path is segmented, and marking all sub-character strings after the character string of the directory path is segmented in a list. For example, if the string of the directory path is "/a/B/C/D/", the segmented substrings are "a", "B", "C", "D", where the last substring "D" is the name of the current task and is also the name of the corresponding java item and service.
The last sub-string separated by the string of the directory path is the name of the current service, and the data of the item referenced by the java item extracted by the pon file is the name of the service referenced by the current service. Preferably, two empty lists can be defined and respectively recorded as a master list and a slave list, the last sub-string of the string partition of the directory path is added into the master list, the data of the item referenced by the java item extracted by the pore file is added into the slave list, the master list contains the name of the current service, and the slave list contains the names of all the services referenced by the current service.
Finally, it should be noted that: the above embodiments are merely preferred embodiments of the present invention for illustrating the technical solution of the present invention, but not limiting the scope of the present invention; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions; that is, even though the main design concept and spirit of the present invention is modified or finished in an insubstantial manner, the technical problem solved by the present invention is still consistent with the present invention, and all the technical problems are included in the protection scope of the present invention; in addition, the technical scheme of the invention is directly or indirectly applied to other related technical fields, and the technical scheme is included in the scope of the invention.
Claims (9)
1. A method for analyzing a reference relation between java items is characterized by comprising the following steps:
step 1, constructing java items for realizing services based on jenkins pipelines;
step 2, copying a python script formed by packing source codes of java items into a jenkins working space;
step 3, reading a pore file of the java item through the python script, and extracting data of the item referenced by the java item;
step 4, acquiring a directory path of the jenkins working space;
step 5, dividing the character string of the directory path into a plurality of sub character strings;
and 6, marking the last sub-string segmented in the step 5 as the name of the current service, and marking the data extracted in the step 2 as the name of the service referenced by the current service.
2. The method for resolving a referential relationship among java items according to claim 1, wherein the step 1 comprises: step 11, pulling source codes of java items from a Git warehouse; and step 12, packaging the source code into a python script, and waiting for the execution of the python script.
3. The method according to claim 1, wherein in step 2, the jenkins workspace is the last directory of the task for constructing the java item, and the pore file is located in the last directory of the task for constructing the java item.
4. The method for analyzing the reference relation between java items according to claim 1, wherein in step 2, the name of the task for constructing the java item is set as the name of the java item.
5. The method for resolving a reference relationship between java items according to claim 1, wherein the step 3 comprises: step 31, reading configuration information of the pom file as a character string by a python script writing file reading method; and 32, acquiring coordinate information defining a unique identifier of the java item from the character string, and extracting data of the item referenced by the java item from the first coordinate information.
6. The method of claim 5, wherein in step 32, a regular expression is used to obtain coordinate information defining a unique identifier of a java item from a character string.
7. The method of claim 5, wherein in step 32, a regular expression is used to extract data of the item referenced by the java item from the first coordinate information.
8. The method for resolving a reference relationship between java items according to claim 1, wherein the step 5 comprises: step 51, defining an empty character string, namely a marked character string, defining an empty list and namely a marked list; step 52, using the forward slash symbol as a keyword for cyclic traversal to circularly traverse the character string of the directory path; step 53, when the traversed element is not a forward slash symbol, adding the current element to the tail of the marking character string, when the traversed element is a forward slash symbol, skipping over the current element and judging the length of the marking character string, when the length of the marking character string is not 0, adding the current marking character string to the marking list, and resetting the marking character string to be empty; step 54, repeating step 53 until the character string of the directory path is segmented, and marking all sub-character strings after the character string of the directory path is segmented in the list.
9. The method for resolving a referential relationship among java items according to claim 1, further comprising: and 7, defining two empty lists, namely a master list and a slave list, respectively, adding the last sub-character string segmented in the step 5 into the master list, adding the data extracted in the step 2 into the slave list, wherein the master list contains the names of the current service, and the slave list contains the names of all the services referenced by the current service.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410161497.9A CN117707547B (en) | 2024-02-05 | 2024-02-05 | Method for analyzing quotation relation among java items |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410161497.9A CN117707547B (en) | 2024-02-05 | 2024-02-05 | Method for analyzing quotation relation among java items |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117707547A true CN117707547A (en) | 2024-03-15 |
CN117707547B CN117707547B (en) | 2024-05-28 |
Family
ID=90153843
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410161497.9A Active CN117707547B (en) | 2024-02-05 | 2024-02-05 | Method for analyzing quotation relation among java items |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117707547B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20180119962A (en) * | 2017-04-26 | 2018-11-05 | 주식회사 평화이즈 | System for analysing the effect of source code modification |
CN109634612A (en) * | 2018-12-04 | 2019-04-16 | 浙江数链科技有限公司 | Continuous integrating method, system, computer equipment and storage medium |
CN109947711A (en) * | 2018-08-22 | 2019-06-28 | 重庆金康特智能穿戴技术研究院有限公司 | A kind of multilingual file automating management method in pair of IOS project development process |
CN111258595A (en) * | 2020-03-13 | 2020-06-09 | 山东超越数控电子股份有限公司 | PyInstaler-based python source code packaging method |
CN111475422A (en) * | 2020-06-28 | 2020-07-31 | 四川新网银行股份有限公司 | Dependence checking method based on Jenkins tool |
CN114327580A (en) * | 2021-11-16 | 2022-04-12 | 中国电信股份有限公司 | Management method, system, equipment and storage medium based on software warehouse |
CN115357898A (en) * | 2022-07-08 | 2022-11-18 | 深圳开源互联网安全技术有限公司 | Dependency analysis method, device and medium for JAVA component |
-
2024
- 2024-02-05 CN CN202410161497.9A patent/CN117707547B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20180119962A (en) * | 2017-04-26 | 2018-11-05 | 주식회사 평화이즈 | System for analysing the effect of source code modification |
CN109947711A (en) * | 2018-08-22 | 2019-06-28 | 重庆金康特智能穿戴技术研究院有限公司 | A kind of multilingual file automating management method in pair of IOS project development process |
CN109634612A (en) * | 2018-12-04 | 2019-04-16 | 浙江数链科技有限公司 | Continuous integrating method, system, computer equipment and storage medium |
CN111258595A (en) * | 2020-03-13 | 2020-06-09 | 山东超越数控电子股份有限公司 | PyInstaler-based python source code packaging method |
CN111475422A (en) * | 2020-06-28 | 2020-07-31 | 四川新网银行股份有限公司 | Dependence checking method based on Jenkins tool |
CN114327580A (en) * | 2021-11-16 | 2022-04-12 | 中国电信股份有限公司 | Management method, system, equipment and storage medium based on software warehouse |
CN115357898A (en) * | 2022-07-08 | 2022-11-18 | 深圳开源互联网安全技术有限公司 | Dependency analysis method, device and medium for JAVA component |
Non-Patent Citations (4)
Title |
---|
TREVOR DUNLAP等: "Finding Fixed Vulnerabilities with Off-the-Shelf Static Analysis", 《2023 IEEE 8TH EUROPEAN SYMPOSIUM ON SECURITY AND PRIVACY (EUROS&P)》, 31 July 2023 (2023-07-31), pages 489 - 505, XP034387627, DOI: 10.1109/EuroSP57164.2023.00036 * |
云端源想IT培训: "Maven简介:一站式解决Java项目依赖问题!", Retrieved from the Internet <URL:https://zhuanlan.zhihu.com/p/670734489> * |
测试加: "python操作jenkins初探", Retrieved from the Internet <URL:https://zhuanlan.zhihu.com/p/509498110> * |
高凡石: "基于微服务的边缘计算网关设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》, 15 April 2021 (2021-04-15), pages 136 - 109 * |
Also Published As
Publication number | Publication date |
---|---|
CN117707547B (en) | 2024-05-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10095499B2 (en) | Optimization for multi-project package manager | |
CN108139891B (en) | Method and system for generating suggestions to correct undefined token errors | |
US8028276B1 (en) | Method and system for generating a test file | |
CN109508191A (en) | A kind of code generating method and system | |
US10203953B2 (en) | Identification of duplicate function implementations | |
US20060080329A1 (en) | Systems and methods for creating a template from an existing file | |
CN112540862A (en) | Interface document data generation method, device, equipment and storage medium | |
CN111045860A (en) | Improving conflict resolution within synchronized composite part-based digital assets | |
CN112527291A (en) | Webpage generation method and device, electronic equipment and storage medium | |
CN113568604B (en) | Method and device for updating wind control strategy and computer readable storage medium | |
CN113515303B (en) | Project transformation method, device and equipment | |
US20040098712A1 (en) | System and apparatus for dynamically upgrading concentrated executable computer software code | |
CN117707547B (en) | Method for analyzing quotation relation among java items | |
CN113342749A (en) | File path matching method, device, equipment and computer readable storage medium | |
CN111898762B (en) | Deep learning model catalog creation | |
CN114356404A (en) | Interface document generating method, system and computer readable storage medium | |
CN112130860A (en) | JSON object analysis method and device, electronic device and storage medium | |
JP7059757B2 (en) | API processing method, terminal, API processing program | |
CN111949309A (en) | Method and device for pulling IDL file, computer equipment and storage medium | |
CN113408250B (en) | Project file processing method and device | |
CN112015497A (en) | Skin changing method and device | |
Omori et al. | Lightweight Operation History Graph for Traceability on Program Elements | |
CN111522627B (en) | Docker mirror image management method, device, equipment and medium | |
CN112379891B (en) | Data processing method and device | |
EP4303719A1 (en) | Automated generation of web applications based on wireframe metadata generated from user requirements |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |