1 Star 0 Fork 0

蘑菇头老大/happy-api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile 3.89 KB
一键复制 编辑 原始数据 按行查看 历史
蘑菇头老大 提交于 2024-11-26 11:00 . update Jenkinsfile.
pipeline {
agent any
environment {
IMAGE_NAME = "swr.cn-north-4.myhuaweicloud.com/sysy-devops/${JOB_NAME}:${BUILD_ID}"
SWR_CREDS = credentials('swr')
}
parameters {
choice(name: 'BUILD_ENV', choices: 'dev\ntest', description: '请选择部署环境:')
}
stages {
stage('编译') {
steps {
script {
configFileProvider([configFile(fileId: "maven-global-settings", variable: 'MAVEN_SETTINGS_ENV')]) {
docker.image("maven:3-jdk-8-alpine").inside("-v /root/.m2:/root/.m2") {
sh "mvn -s ${MAVEN_SETTINGS_ENV} clean deploy -B -Dfile.encoding=UTF-8 -Dmaven.test.skip=true -U"
}
}
}
}
}
stage('推送镜像') {
steps {
script {
docker.withRegistry("https://swr.cn-north-4.myhuaweicloud.com", "swr") {
def app = docker.build("$IMAGE_NAME")
app.push()
}
sh "docker rmi -f $IMAGE_NAME"
}
}
}
stage("Ansible") {
steps{
script {
docker.image('willhallonline/ansible:2.14.14-bookworm-slim').inside() {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "playbook"]], submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'ssh', url: '[email protected]:mmbluex/jenkins-ansible-playbooks.git']]])
sh 'pwd'
sh "ls -lh"
dir("${WORKSPACE}/playbook") {
ansiColor('xterm') {
ansiblePlaybook(
playbook: "playbook_java.yml",
inventory: "hosts/${params.BUILD_ENV}.ini",
disableHostKeyChecking: true,
colorized: true,
credentialsId: "ssh",
extraVars: [
lang : "java",
app : [value: "happy-api", hidden: false],
image : [value: "${env.IMAGE_NAME}", hidden: false],
tag : "${BUILD_ID}"
]
)
}
}
}
}
}
}
stage('通知') {
steps {
script {
dingding()
}
}
}
}
}
def dingding() {
def ds = new Date().format("yyyy-MM-dd HH:mm:ss")
def patchOrg = """
{
"msgtype": "link",
"link": {
"title": "【DEV】环境 happy-api 构建成功",
"text": "构建编号:${BUILD_NUMBER}
构建人:Jim老师
构建时间:${ds}",
"picUrl": "http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png",
"messageUrl": "${BUILD_URL}"
}
}
"""
def response = httpRequest(
url: "https://oapi.dingtalk.com/robot/send?access_token=7f786dab644e6787dfa99118f05103b73825a8564760000e8f5bcac80d2d1599",
httpMode: 'POST',
requestBody: patchOrg,
contentType: 'APPLICATION_JSON_UTF8'
)
println('Status: '+response.status)
println('Response: '+response.content)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/mmbluex/happy-api.git
[email protected]:mmbluex/happy-api.git
mmbluex
happy-api
happy-api
master

搜索帮助