반응형
참조: Slack notification 플러그인 - Slack Notification | Jenkins plugin
- Jenkins 에 Slack 플러그인 설치
- Jenkins 서버에 이 플러그인을 설치
- Jenkins 홈페이지에서 Manage Jenkins로 이동.
Manage Plugins으로 이동합. - 탭을 Available로 변경.
- "slack"을 검색.
- 설치할 항목 옆의 체크박스를 선택 및 설치
- Slack 내 App 생성 및 WorkGroup 에 설치
- 필요 시 Slack 계정을 생성: https://slack.com/
- https://api.slack.com/apps 로 이동하여 "Create New App"를 클릭
- "From an app manifest"를 클릭.
- 워크스페이스를 선택.
- Slack이 제공하는 예제 매니페스트를 삭제.
- "YAML"을 클릭.
- 다음 내용을 텍스트 상자에 복붙
-
#bot 설정 display_information: name: Jenkins features: bot_user: display_name: Jenkins사용자이름 always_online: true oauth_config: scopes: bot: - channels:read - chat:write - chat:write.customize - files:write - reactions:write - users:read - users:read.email - groups:read settings: org_deploy_enabled: false socket_mode_enabled: false token_rotation_enabled: false
- "Next"를 클릭.
- "Create"를 클릭.
- "Install App to Workspace"를 클릭.
- "Allow"를 클릭.
- 사이드바에서 "OAuth & Permissions"를 클릭.
- "Bot User OAuth Access Token"을 복사
- Jenkins에서: "Manage Jenkins → System"에서 Slack 설정으로 이동.
- Jenkins에서: "Add"를 클릭하여 새 "Secret text" 자격 증명을 생성하고 봇 사용자 토큰을 입력.
- Jenkins에서: 드롭다운에서 새 "Secret text"를 선택.
- Jenkins에서: 기본 채널을 추가
- Jenkins에서: "Custom slack app bot user" 옵션을 선택.
- 알림을 받으려는 Slack 채널에 Jenkins 봇 사용자를 초대.
- Jenkins에서: "test connection"을 클릭. 기본 채널 / 기본 멤버에게 메시지가 전송되는지 확인.
- pipeline 코드
slackSend color: "good", message: "Message from Jenkins Pipeline"
- 사용 예제
-
pipeline { agent any stages { stage('Test') { steps { timestamps { echo "hello world" } } } } post { success { timestamps { echo "Sending Slack notification" slackSend(color: 'good', message: "Message from Jenkins Pipeline - ${currentBuild.fullDisplayName}") } } } }
- 빌드 로그
- slack 메세지
-
반응형
'초짜 IT보이 서바이벌 스토리' 카테고리의 다른 글
2025 년 #가트너 (#Gartner) 에서 발표한 10가지 주요 전략 기술 트렌드 (2) | 2024.12.09 |
---|---|
2024 년 #가트너 (#Gartner) 에서 발표한 10가지 주요 전략 기술 트렌드 (1) | 2024.02.07 |
사내 메신저 사용의 모범사례 - Best Practices for Instant Messaging at Work (0) | 2023.06.21 |
#Jenkins #Scheduler #Chrontab #Setting (0) | 2023.04.25 |
#webapp works only with #war #packaging (0) | 2023.03.28 |