Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the pipelined configuration of Jenkinsfile

Shulou Source: shulou.com Published: 2022-06-02 02:35:24 10月03日 Update

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.

Tags: Compilation pipelining pipelining configuration code more knowledge articles details updates utility hours that is work sessions constants articles modules click to see knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux OPPO Reno Docker vpn