1 Star 0 Fork 2

ytq12875/iWeb2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile 3.20 KB
一键复制 编辑 原始数据 按行查看 历史
11547299 提交于 2022-09-12 14:53 . Update
pipeline{
agent {
label "master"
}
parameters {
string(name: "branch", defaultValue: "master", description: "Git分支")
}
environment {
docker_image = 'iweb'
docker_container = 'iWebObj'
}
stages{
stage("同步最新代码"){
steps{
sh '''
mkdir -p iWeb
'''
dir("iWeb"){
checkout(
[
$class: "GitSCM",
branches: [[name: "$params.branch"]],
extensions: [[$class: "CleanBeforeCheckout"]],
userRemoteConfigs: [[url: "git@github.com:princeqjzh/iWeb.git"]]
]
)
}
}
}
stage("编译打包"){
steps{
sh '''
cd ${WORKSPACE}/iWeb
mvn clean install -Dmaven.test.skip=true
mv target/iWeb.war target/ROOT.war
'''
}
}
stage("清理docker环境"){
steps{
script{
try{
sh 'docker stop ${docker_container}'
}catch(exc){
echo '${docker_container} container is not running!'
}
try{
sh 'docker rm ${docker_container}'
}catch(exc){
echo '${docker_container} container does not exist!'
}
try{
sh 'docker rmi ${docker_image}'
}catch(exc){
echo '${docker_image} image does not exist!'
}
}
}
}
stage("创建新docker镜像"){
steps{
script{
try{
sh '''
cd ${WORKSPACE}/iWeb
docker build -t ${docker_image} .
'''
}catch(exc){
echo 'Make ${docker_image} docker image failed, please check the environment!'
}
}
}
}
stage("启动docker容器"){
steps{
script{
try{
sh 'docker run --name ${docker_container} -d -p 8111:8080 ${docker_image}'
}catch(exc){
echo 'Start docker image failed, please check the environment!'
}
}
}
}
stage("健康接口测试"){
steps{
sh '''
cd ${WORKSPACE}/iWeb
mvn test
'''
}
}
}
post {
always {
junit (
testResults: 'iWeb/target/surefire-reports/*.xml'
, allowEmptyResults: true
)
emailext body: '$DEFAULT_CONTENT', recipientProviders: [[$class: 'RequesterRecipientProvider']], subject: '$DEFAULT_SUBJECT'
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ytq12875/iWeb_2.git
git@gitee.com:ytq12875/iWeb_2.git
ytq12875
iWeb_2
iWeb2
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385