Comments (12)
发送失败应该会在jenkins控制台输出错误信息。
看配置应该是参数错误,你换成 TEXT 类型的消息试试:
type: 'TEXT'
from dingtalk-plugin.
遇到问题先看日志,再查文档,最后提 issue。
更多的使用案例参考:https://jenkinsci.github.io/dingtalk-plugin/examples/text.html
from dingtalk-plugin.
@liuweiGL 您好,确实没有日志,文档我也看了四次。找不到原因很困惑,希望得到你们的帮助,谢谢
pipeline script 部分配置
stage ("build") {
container("golang") {
sh """
git config --global url."https://oauth2:[email protected]".insteadOf "https://git.test.com"
export GOPROXY=https://goproxy.io,direct
export GOPRIVATE=git.test.com
export GOPATH=/home/jenkins
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main 1111.go
"""
}
}
stage('text'){
post {
failure {
dingtalk (
robot: '6cc574c3-17fa-4e0c-8724-f7de3376e1b6',
type: 'TEXT',
text: [
'go build失败了,请检查!'
]
)
}
}
}
jenkins 日志输出
git log -n 1 --pretty=format:%h
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (build)
[Pipeline] container
[Pipeline] {
[Pipeline] sh
+ git config --global url.https://oauth2:[email protected] https://git.test.com
+ export GOPROXY=https://goproxy.io,direct
+ export GOPRIVATE=git.test.com
+ export GOPATH=/home/jenkins
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main 1111.go
stat 1111.go: no such file or directory
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
from dingtalk-plugin.
pipeline {
agent any
stages {
stage('Hello') {
steps {
dingtalk (
robot: 'your root id',
type: 'TEXT',
text: [
'go build失败了,请检查!'
]
)
}
}
}
}
from dingtalk-plugin.
@liuweiGL 这种是声明式pipeline方式。我是用的pipeline script。请问与使用pipeline的方式有没关系呢,谢谢
from dingtalk-plugin.
这两种方式调用没有区别。
应该是你的 pipeline 写错了,stage ("build") 节点报错,不会触发 stage ("text") 节点的 failure 事件。
from dingtalk-plugin.
@liuweiGL 我尝试过这样写,也不行
stage ("build") {
container("golang") {
sh """
git config --global url."https://oauth2:[email protected]".insteadOf "https://git.test.com"
export GOPROXY=https://goproxy.io,direct
export GOPRIVATE=git.test.com
export GOPATH=/home/jenkins
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main 1111.go
"""
}
post {
failure {
dingtalk (
robot: '6cc574c3-17fa-4e0c-8724-f7de3376e1b6',
type: 'TEXT',
text: [
'go build失败了,请检查!'
]
)
}
}
}
也尝试过把 stage('text'){}放在pipeline 最后。 实在无解了,特此劳烦请教作者您,谢谢。网上查阅到的资料均说pipeline script方式不支持钉钉插件,需要用声明式pipeline。
from dingtalk-plugin.
你在 failure 里面输出一个 echo,看看是否执行到了。
from dingtalk-plugin.
没有输出,不知道为什么没有执行到,估计只能改用声明式pipeline或者通过脚本调用钉钉发送通知了。
stage ("build") {
container("golang") {
sh """
git config --global url."https://oauth2:[email protected]".insteadOf "https://git.test.com"
export GOPROXY=https://goproxy.io,direct
export GOPRIVATE=git.test.com
export GOPATH=/home/jenkins
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main 1111.go
"""
}
post {
failure {
echo "aaaaaaaaaaaaaaaaaaa"
dingtalk (
robot: '6cc574c3-17fa-4e0c-8724-f7de3376e1b6',
type: 'TEXT',
text: [
'go build失败了,请检查!'
]
)
}
}
}
stage('text'){
post {
failure {
echo "aaaaaaaaaaaaaaaaaaa"
dingtalk (
robot: '6cc574c3-17fa-4e0c-8724-f7de3376e1b6',
type: 'TEXT',
text: [
'go build失败了,请检查!'
]
)
}
}
}
+ git config --global url.https://oauth2:[email protected] https://git.test.com
+ export GOPROXY=https://goproxy.io,direct
+ export GOPRIVATE=git.test.com
+ export GOPATH=/home/jenkins
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main 1111.go
stat 1111.go: no such file or directory
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
from dingtalk-plugin.
我真是搞不明白,你到现在都还纠结什么申明式 pipeline干嘛?
你的 failure 事件都没执行,跟插件有什么关系呢?
很明显就是你的 container 节点异常,导致整个 pipeline 终止执行,直接退出了。
from dingtalk-plugin.
@liuweiGL 我们代码编译是在container 容器中做的,jenkins master和slave基于k8s pod跑的。有什么解决办法吗? 需求是针对每个pipeline步骤做失败检测,即失败了则发送钉钉通知告知相关信息。
from dingtalk-plugin.
stage('DingDing') {
script {
def msg = "构建失败,请及时查看原因"
def imageUrl = "https://www.iconsdb.com/icons/preview/red/x-mark-3-xxl.png"
def dingdingtoken = "https://oapi.dingtalk.com/robot/send?access_token=****************************"
if (currentBuild.currentResult=="SUCCESS"){
imageUrl= "http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png"
msg ="发布成功"
}
sh "sh ${JENKINS_HOME}/dingding.sh ${BUILD_TAG} ${BUILD_URL} ${msg} ${imageUrl} ${dingdingtoken}"
}
}
dingding.sh
#!/bin/sh
title=$1
messageUrl=$2
picUrl=$4
text=$3
PHONE="158215*****"
TOKEN=$5
DING="curl -H \"Content-Type: application/json\" -X POST --data '{\"msgtype\": \"link\", \"link\": {\"messageUrl\": \"${messageUrl}\", \"title\": \"${title}\", \"picUrl\": \"${picUrl}\", \"text\": \"${text}\",}, \"at\": {\"atMobiles\": [${PHONE}], \"isAtAll\": false}}' ${TOKEN}"
eval $DING
我是这么的 ...
from dingtalk-plugin.
Related Issues (20)
- Pipeline 中无法使用插件环境变量 HOT 5
- Configuration-as-Code 支持 HOT 6
- 安装了Ding Talk插件在系统配置找不到钉钉配置
- Jenkins升级后无法使用 HOT 2
- jenkins 2.406版本无法使用Dingtalk HOT 1
- 使用流水线无法发送消息 HOT 1
- 系统配置好了Jenkins,测试也可以正常发消息,在流水线中发布不成功 HOT 1
- ERROR: Step ‘Dingding Json Pusher’ aborted due to exception: HOT 2
- 自定义机器人下线后,这个还能用吗 HOT 6
- 配置钉钉手机号,at人是假at,没有提醒,不可点击 HOT 1
- 通知时机增加"修正状态" HOT 1
- 新版本无法使用
- dingtalk插件使用报错,测试error HOT 3
- 禁用了内置消息,freestyle的markdown格式不生效,钉钉通知的标题是默认的“jenkins构建通知”
- [BUG]关键字的帮助按钮点击后报错
- 钉钉点测试后无反应 F12报错 HOT 6
- dingtalk-plugin版本2.7.0,点击无反应 HOT 2
- 调用DingTalk报错FormatConversionException HOT 2
- 选中 `禁用内置消息` 复选框后下方无法在 `自定义内容` 和 `自定义消息` 之间切换
- TODO
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dingtalk-plugin.