💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## Jenkins流水线整合钉钉 在程序部署成功后,可以通过钉钉的机器人及时向群众发送部署的最终结果通知 - 安装插件 | 安装插件 | | :----------------------------------------------------------: | | ![](https://img.kancloud.cn/6d/a7/6da71594fc336b75e353bd6052de461a_1920x409.png) | - 钉钉内部创建群组并构建机器人 | 钉钉内部创建群组并构建机器人 | | :----------------------------------------------------------: | | ![](https://img.kancloud.cn/8e/96/8e96972788ae62ae23e394faa68c551b_1631x562.png) | | ![](https://img.kancloud.cn/0d/c4/0dc48335c11594daf90f42912300c4b8_1611x569.png)| | ![](https://img.kancloud.cn/f3/8b/f38b05d3df75b99d5d0ef2175479a83b_1616x589.png) | 最终或获取到Webhook信息 ``` https://oapi.dingtalk.com/robot/send?access_token=kej4ehkj34gjhg34jh5bh5jb34hj53b4 ``` - 系统配置添加钉钉通知 | 配置钉钉通知 | | :----------------------------------------------------------: | |![](https://img.kancloud.cn/5c/a9/5ca9886ed6d65b3e86f6f1074a1b70a2_1923x786.png) | - 任务中追加流水线配置 ```sh pipeline { agent any environment { sonarLogin = '2bab7bf7d5af25e2c2ca2f178af2c3c55c64d5d8' harborUser = 'admin' harborPassword = 'Harbor12345' harborHost = '192.168.11.12:8888' harborRepo = 'repository' } stages { stage('拉取Git代码'){ steps { checkout([$class: 'GitSCM', branches: [[name: '$tag']], extensions: [], userRemoteConfigs: [[url: 'http://49.233.115.171:8929/root/lsx.git']]]) } } stage('Maven构建代码'){ steps { sh '/var/jenkins_home/maven/bin/mvn clean package -DskipTests' } } stage('SonarQube检测代码'){ steps { sh '/var/jenkins_home/sonar-scanner/bin/sonar-scanner -Dsonar.sources=./ -Dsonar.projectname=${JOB_NAME} -Dsonar.projectKey=${JOB_NAME} -Dsonar.java.binaries=target/ -Dsonar.login=${sonarLogin}' } } stage('制作自定义镜像'){ steps { sh '''cd docker mv ../target/*.jar ./ docker build -t ${JOB_NAME}:$tag . ''' } } stage('推送自定义镜像'){ steps { sh '''docker login -u ${harborUser} -p ${harborPassword} ${harborHost} docker tag ${JOB_NAME}:$tag ${harborHost}/${harborRepo}/${JOB_NAME}:$tag docker push ${harborHost}/${harborRepo}/${JOB_NAME}:$tag''' } } stage('通知目标服务器'){ steps { sshPublisher(publishers: [sshPublisherDesc(configName: 'centos-docker', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: "/usr/bin/deploy.sh $harborHost $harborRepo $JOB_NAME $tag $port", execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) } } } post { success { dingtalk ( robot: 'Jenkins-DingDing', type:'MARKDOWN', title: "success: ${JOB_NAME}", text: ["- 成功构建:${JOB_NAME}项目!\n- 版本:${tag}\n- 持续时间:${currentBuild.durationString}\n- 任务:#${JOB_NAME}"] ) } failure { dingtalk ( robot: 'Jenkins-DingDing', type:'MARKDOWN', title: "fail: ${JOB_NAME}", text: ["- 失败构建:${JOB_NAME}项目!\n- 版本:${tag}\n- 持续时间:${currentBuild.durationString}\n- 任务:#${JOB_NAME}"] ) } } } ``` - 查看效果 | 钉钉通知效果 | | :----------------------------------------------------------: | | ![](https://img.kancloud.cn/90/2c/902c97891df095d0d7bc0bce80180858_1617x716.png) |