$ curl -X POST -H 'Authorization: Bearer gcJU95ghZ1i2VlyYVYfy1FES63hA9kXAvL9rPb5epjn' -F 'message=Hello Line' https://notify-api.line.me/api/notify {"status":200,"message":"ok"} $ |
#!groovy node { try { stage 'Checkout' checkout scm stage 'Build and test' sh './gradlew clean check' currentBuild.result = 'SUCCESS' } catch (err) { currentBuild.result = 'FAILURE' } stage 'Notify' notifyLINE('0nWiXPLLlSPpYnkdRhgIXirmmYFNcjh4VQyu2VQja7x', currentBuild.result) }
def notifyLINE(token, result) { def isFailure = result == 'FAILURE'
def url = 'https://notify-api.line.me/api/notify' def message = "Build ${env.BRANCH_NAME}, result is ${result}. \n${env.BUILD_URL}" def imageThumbnail = isFailure ? 'http://developers.linecorp.com/blog/wp-content/uploads/2016/10/moon.png' : '' def imageFullsize = isFailure ? 'http://developers.linecorp.com/blog/wp-content/uploads/2016/10/moon.png' : ''
sh "curl ${url} -H 'Authorization: Bearer ${token}' -F 'message=${message}' -F 'imageThumbnail=${imageThumbnail}' -F 'imageFullsize=${imageFullsize}'" } |
def notifyLINE(token, result, branchName, branchUrl) { def isFailure = result == 'FAILURE'
def url = 'https://notify-api.line.me/api/notify' def message = "Build ${branchName}, result is ${result}. \n${branchUrl}" def imageThumbnail = isFailure ? 'http://developers.linecorp.com/blog/wp-content/uploads/2016/10/moon.png' : '' def imageFullsize = isFailure ? 'http://developers.linecorp.com/blog/wp-content/uploads/2016/10/moon.png' : ''
def command = "curl ${url} -H 'Authorization: Bearer ${token}' -F 'message=${message}' -F 'imageThumbnail=${imageThumbnail}' -F 'imageFullsize=${imageFullsize}'" print command command.execute() } notifyLINE('6PUqyn2iEJ1jxgfT0HmuR6vb61H8vKPstzv2LOtSMZb', manager.build.result, 'TestJob', 'http://testJob.com/jenkins/job/TestJob/' + manager.build.number) |
참고