In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to achieve multi-module parallel construction and release in micro-service mode". The content in this article is simple and clear, and it is easy to learn and understand. let's study and learn "how to achieve multi-module parallel construction and release in micro-service mode"!
There are many service modules in the micro-service project. In order to facilitate management, the project needs to be standardized. GitLabGroup is used to manage the whole project, each project corresponds to a micro-service, and each micro-service corresponds to a Jenkins job. When we start publishing, we need to manually select each service and then release it. It is not very convenient when there are a lot of modules. Create a Jenkins project for unified management, bind GitLab group information, and then call the Gitlab API to get project information. The user selects the micro-service to publish, and then triggers each pipeline to publish the service in parallel according to the service name to build and publish.
Let's first look at how to use the parallel syntax in pipeline. Here are two examples: parallel tasks and parallel phases.
Parallel task
First we need to define the name of each task and the corresponding operation, which can be achieved through a Map type parameter. An empty map is defined here, and then two tasks are added to the map, build01 and build02, whose operation is to execute the shell command. Finally, it runs through parallel.
Def tasks = [:] / define the task name and task to be parallel tasks ["build01"] = {sh "ls"} tasks ["build02"] = {sh "ls"} / / parallel parallel tasks
Parallel phase
Parallel stage is also a frequently used running mode, and we can use this way to solve the unnecessary waste of time, especially when running automated tests on various platforms, we do not have to wait until the verification of the windows platform is completed before verification in the Linux system. Instead, it runs directly in each platform at the same time, speeding up the testing speed. We can also use the failFast parameter to configure whether one of the tasks fails as well as the other, with a parameter of Boolean type (true false).
This example is officially provided by jenkins, and the general content is to automate testing in different system environments in parallel.
Pipeline {agent none stages {stage ('Run Tests') {parallel {stage (' Test On Windows') {agent {label "windows"} steps {bat "run-tests.bat "} post {always {junit" * * / TEST-*.xml "} stage ('Test On Linux') { Agent {label "linux"} steps {sh "run-tests.sh"} post {always { Junit "* / TEST-*.xml"}
Implementation of master control Job
First, we use static data to store the name of the project to be published as a List, and define a Map to store parallel tasks. Define buildStatus to display project error messages (the information is formatted here). Use build for project triggering. Here, each failed task storage is displayed in the pipeline log.
Def jobs = ["test2", "demo-test-service"] def parallelMap = [:] def buildStatus = [:] jobs.each {println (it) parallelMap [it] = {try {build job: "${it}", parameters: [string (name: 'branchName') Value: 'Dev')} catch (e) {println ("${it}" + e) buildStatus [it] = e} parallel parallelMap / / judgment status for (I in buildStatus.keySet ()) {currentBuild.description = "build Information" currentBuild.description + = ("\ nProject name->" + I + "error Information:-> "+ buildStatus [I])}
Running effect
Basically each module corresponds to a pipeline project. Sometimes we need to set up a centralized control project to trigger the pipeline corresponding to each module service in an orderly manner according to the set parameters. When there is no release order between modules, we can use Pipeline's Parallel syntax to build the project in parallel. Speed up the release speed and reduce the cost of repeated manual operation.
Thank you for your reading. the above is the content of "how to achieve multi-module parallel construction and release in micro-service mode". After the study of this article, I believe you have a deeper understanding of how to achieve multi-module parallel construction and release under micro-service mode, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.