Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- group-by
- 슬랙
- 실행계획
- 워크벤치
- Cloud
- 배타서브타입
- 물리모델
- 완전서브타입
- 오라클
- 중복서브타입
- SQL
- 빈줄제거
- 인덱스
- Oracle
- 서브타입
- bc정규형
- Workbench
- 무료티어
- order-by
- IntelliJ
- index
- 클라우드
- 젠킨스
- Slack
- 인텔리제이
- jenkins
- 정규형
- vue3
- mysql
- 불완전서브타입
Archives
- Today
- Total
domsam - IT 기술 블로그
[#2] Jenkins(젠킨스) - Slack(슬랙) 연동 본문
반응형
Pipeline script
def slackMessageBuilder = ""
pipeline {
environment {
// 슬랙 메세지 전송 관련 변수
SLACK_CHANNEL = "#jenkins-alarm" //젠킨스 메세지 채널 이름
SLACK_SUCCESS_COLOR = "#2C953C" //성공 메세지 색상
SLACK_FAIL_COLOR = "#FF3232" //실패 메세지 색상
SLACK_MESSAGE_UNIT = "=================================================================="
}
stages {
stage('Start') {
steps {
script {
slackMessageBuilder =
"${env.SLACK_MESSAGE_UNIT}" + "\n" +
"@here \n" +
":pencil: ${env.JOB_NAME} 배포 파이프라인 실행 결과 리포트입니다. (<${env.BUILD_URL}|${currentBuild.displayName}>) \n"
slackSend (
channel: env.SLACK_CHANNEL,
color: env.SLACK_SUCCESS_COLOR,
message: ":information_source: @here ${env.JOB_NAME} 배포 파이프라인이 시작되었습니다. (<${env.BUILD_URL}|${currentBuild.displayName}>)"
)
}
}
} // stage('Start')
stage('작업 제목') {
steps {
//작업 내용
script {
slackMessageBuilder += ":white_check_mark: 작업 내용 성공! \n"
}
}
// steps 작업 중 에러가 발생하면 메세지 전송
post {
failure {
slackSend (
channel: env.SLACK_CHANNEL,
color: env.SLACK_FAIL_COLOR,
message: "${slackMessageBuilder}" + stageFailSlackMessage("작업 제목") + "${env.SLACK_MESSAGE_UNIT}"
)
}
}
}
//작업 반복
stage('End') {
steps {
script {
slackMessageBuilder += ":tada: ${env.JOB_NAME} 배포 파이프라인이 성공적으로 완료되었습니다. :beer:\n" + "${env.SLACK_MESSAGE_UNIT}"
slackSend (
channel: env.SLACK_CHANNEL,
color: env.SLACK_SUCCESS_COLOR,
message: slackMessageBuilder
)
}
}
}
} // stages
}
// 실패 메세지를 생성하는 함수
def stageFailSlackMessage(stageName) {
return ":alert: ${stageName} 단계에서 배포가 실패하였습니다. \n"
}
연동이 잘 되었다면 젠킨스 메세지 채널에 메세지가 뜬다.
'MSA > DevOps' 카테고리의 다른 글
[#1] Jenkins(젠킨스) - Slack(슬랙) 연동 (0) | 2025.10.02 |
---|---|
훈련생 MSA 세팅 (0) | 2025.09.12 |
[Jenkins] 젠킨스 한국 시간 설정 (1) | 2025.07.22 |
FE - Github 협업 (0) | 2025.07.15 |
BE - Github 협업 (0) | 2025.07.14 |