Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Angular+Jenkins to show the build

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you how to use Angular+Jenkins to show the relevant knowledge points of the construction version, the content is detailed, the logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.

As follows:

Uha, let's modify it on the original basis.

Add the file build_info.json to the root directory.

{}

You read it correctly. The content of build_info.json is {}

The build_info.json file is generated when it is built for Jenkinsfile.

The specific implementation ideas are as follows:

Execute Jenkinsfile to generate build_info.json files during the build process

When packaging the project, consider whether to obtain the contents of the build_info.json file for different environments

To facilitate the demonstration, the environment here only considers the production environment.

The above steps are two simple steps, and the most important one is how to write the contents of the build_info.json file.

If you are not familiar with Jenkinsfile-related content, please combine Jenkins Pipeline with Gitlab to achieve automatic construction of Node project articles to read. At this point, your focus is on the content of the article Jenkinsfile, as follows:

Pipeline {agent any tools {nodejs "nodejs"} stages {stage ('Dependency') {steps {sh' npm install'}} # We added a stage here, see below? Stage ('Build') {steps {sh' npm run clean' sh 'npm run build'}

We added a stage to complete our writing to the build_info.json file.

Stage ('Version') {steps {script {def amap =' build_number': BUILD_NUMBER, # Construction number 'job_name': JOB_NAME # Task name] # write to the file writeJSON file: WORKSPACE+'build_info.json', json: amap # WORKSPACE root}

Yeah, the train of thought is OK. Right?

Let's move on to the second step: read the contents of build_info.json, and I intercept the contents of the version.js production environment:

/ / introduce the generated build_info.json file let buildInfo = require ('. / build_info.json'); if (config.env = = 'production') {/ / get the built version number, otherwise get the default version versionObj.version = buildInfo.build_number | | config.version}

After completing the above file, you can publish it to the relevant environment, and if all goes well, you can see the relevant version number on the page.

These are all the contents of the article "how to use Angular+Jenkins to show a built version". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report