当前位置: 首页 > news >正文

Jenkins pipeline 发送邮件及包含附件

Jenkins pipeline 发送邮件及包含附件

设置邮箱开启SMTP服务

此处适用163 邮箱
在这里插入图片描述

  1. 开启POP3/SMTP服务
  2. 通过短信获取TOKEN (保存TOKEN, 后面Jenkins会用到)

Jenkins 邮箱设置

安装 Build Timestamp插件

设置全局凭证

Dashboard -> Manage Jenkins -> Credentials -> Stores scoped to Jenkins -> Domains (global)
新增一个ID,配置对应的用户名,密码(163 开启POP3/SMTP 服务提供的 TOKEN)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

设置邮箱

  1. Dashboard -> Manage Jenkins -> System -> Jenkins Location ->
    System Admin e-mail address: fernando_xxxx@163.com (开启了POP3/SMTP的邮箱地址)
  2. Dashboard -> Manage Jenkins -> System -> Jenkins Location ->
    Extended E-mail Notification:
    SMTP server: smtp.163.com
    SMTP Port: 25
    Advanced -> Credentials: 163_email_user
    Default user e-mail suffix: 163.com
    Default Content Type: HTML (text/html)

在这里插入图片描述

Jenkins pipeline 验证

pipeline {agent anystages {stage('Check and Create Directory') {steps {script {def dir = "zip_files"sh 'rm -fr ${dir}'if (!fileExists(dir)) {sh "mkdir -p ${dir}"}}}}stage('Execute Python Statement') {steps {sh 'python3 -c "print(\'Hello from Python in Jenkins\')"'writeFile file: './zip_files/file1.txt', text: 'This is the content of file1'writeFile file: './zip_files/file2.txt', text: 'This is the content of file2'script {env.ZIP_FILE = "test.zip"}sh "zip -r ${env.ZIP_FILE} ./zip_files/*.txt"}}stage('Send Email') {steps {script {def version = "1.0.${env.BUILD_NUMBER}"emailext (subject: "Build and Package Report for Version ${version}",body: "Please find the attached packaged zip file.",// hide the mail addressto: "9949****@qq.com",attachmentsPattern: env.ZIP_FILE)}}}}
}

在这里插入图片描述

http://www.lryc.cn/news/517598.html

相关文章:

  • 怎么把word试题转成excel?
  • 【机器学习】量子机器学习:当量子计算遇上人工智能,颠覆即将来临?
  • IDEA配置maven和git并如何使用maven打包和git推送到gitlab
  • Supermaven 加入 Cursor:AI 编码新篇章
  • 【2024华为OD-E卷-100分-boss的收入】(题目+思路+JavaC++Python解析)
  • 《Java8实战》汇总
  • Elasticsearch:搜索相关性
  • LeetCode 热题 100_二叉树展开为链表(46_114_中等_C++)(二叉树;先序遍历(递归+数组);先序遍历(递归))
  • uniapp实现在card卡片组件内为图片添加长按保存、识别二维码等功能
  • 最好用的图文识别OCR -- PaddleOCR(2) 提高推理效率(PPOCR模型转ONNX模型进行推理)
  • Redis--20--大Key问题解析
  • 新版2024AndroidStudio项目目录结构拆分
  • STM32内置Flash
  • 华为路由器、交换机、AC、新版本开局远程登录那些坑(Telnet、SSH/HTTP避坑指南)
  • 【Linux】深入理解进程信号机制:信号的产生、捕获与阻塞
  • 前端基础技术全解析:从HTML前端基础标签语言开始,逐步深入CSS样式修饰、JavaScript脚本控制、Ajax异步通信以及WebSocket持久通信
  • Linux存储管理之核心秘密(The Core Secret of Linux Storage Management)
  • excel精简使用工具
  • Flutter鸿蒙化 在鸿蒙应用中添加Flutter页面
  • 为什么页面无法正确显示?都有哪些HTML和CSS相关问题?
  • 如何制作一份出色的公司介绍PPT?
  • Selenium 进行网页自动化操作的一个示例,绕过一些网站的自动化检测。python编程
  • HashMap和HashTable的区别
  • 使用redis来进行调优有哪些方案?
  • macOS 中,默认的 Clang 编译器和 Homebrew 安装的 GCC 都不包含 bits/stdc++.h 文件
  • 2012mfc,自绘列表控件
  • vue3运行时执行过程步骤
  • 常用的AT命令,用于查看不同类型的网络信息
  • Vue3组件通讯——自定义事件(子->父)
  • GLSL 着色器语言