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

What is the pipelined configuration of Jenkinsfile

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article to share with you is about Jenkinsfile pipeline configuration is what, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some gains, not much to say, follow Xiaobian to see it.

Through jenkinsfile, jenkins automatically builds the pipeline for publication, for everyone's reference, for details, please see my code cloud

import java.util.*; import java.text.SimpleDateFormat;node { //Define an update policy, triggered every two hours from 9:00 to 16:00 Monday to Friday properties([ pipelineTriggers([cron('H H(9-16)/5 * * 1-5')]) ]) //define constants def VERSION = '1.0-SNAPSHOT'; def BASIC_MODEL = 'ao-be-basic'; def CENTER_MODEL = 'ao-be-center'; def GATE_MODEL = 'ao-be-gate'; def UI_MODEL = 'ao-be-ui'; def change = true; //pull code stage('pull') { def GIT_COMMIT = checkout(scm: scm, poll: true, changelog: true) echo "$GIT_COMMIT" if(GIT_COMMIT['GIT_COMMIT'] == GIT_COMMIT['GIT_PREVIOUS_COMMIT']){ change = false; } } //compile stage('build') { //if there are no changes, stop compiling if(! change){ return; } docker.image('maven:3-alpine').inside('-v /root/.m2:/root/.m2') { //compile code stage('build-docker-image') { sh 'mvn clean install' sh "chmod +x ./ build/mk.sh && ./ build/mk.sh "+ BASIC_MODEL + " " + BASIC_MODEL + " " + VERSION sh "./ build/mk.sh "+ CENTER_MODEL + " " + CENTER_MODEL + " " + VERSION sh "./ build/mk.sh "+ GATE_MODEL + " " + GATE_MODEL + " " + VERSION } } //compile basic module def aoBeBasicImage = docker.build("com.ao.be/"+BASIC_MODEL+":"+VERSION ," --build-arg JAR_FILE="+BASIC_MODEL + "-" + VERSION + ".jar ./ " + BASIC_MODEL + "/target/docker") def aoBeCenterImage = docker.build("com.ao.be/"+CENTER_MODEL+":"+VERSION ," --build-arg JAR_FILE="+CENTER_MODEL + "-" + VERSION + ".jar ./ " + CENTER_MODEL + "/target/docker") def aoBeGateImage = docker.build("com.ao.be/"+GATE_MODEL+":"+VERSION ," --build-arg JAR_FILE="+GATE_MODEL + "-" + VERSION + ".jar ./ " + GATE_MODEL + "/target/docker") def aoBeUiImage = docker.build("com.ao.be/"+UI_MODEL+":"+VERSION ,UI_MODEL) } //clear the false image stage('prune images') { sh 'docker image prune -f' }} The above is what the pipeline configuration of Jenkinsfile is. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow 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

Internet Technology

Wechat

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

12
Report