Programmer:)

[Jenkins] Telegram 연동하기 본문

DEV/Jenkins

[Jenkins] Telegram 연동하기

ryeggg 2024. 7. 12. 09:53
반응형

jenkins 빌드시 실패, 성공 여부와 실패했을 경우 에러코드 그리고 성공했다면 빌드 버전을 텔레그램 메세지로 공유받고 싶었다.

 

 

젠킨스에서 Telegram Bot Plugin 설치

 

 

 

텔레그램에 젠킨스 메세지를 출력할 봇 생성

 

토큰값 복사해서 [TOKEN]에 집어넣어서 이동

https://api.telegram.org/bot[TOKEN]/getUpdates

 

그러면 {"ok":true, "result:[]} 이런 형식이 뜨는데 텔레그램 봇에 hi입력후 새로고침을 한다.

"chat":{"id":939393939, "first_name~~~} 중간에 이런 내용이 있는데 저 아이디가 chat id이다 . 

 

필요한 재료가 준비되었다.

토큰값 , chat id

 

pipeline {
    agent any
    
    environment{
        MESSAGE = "HI"
    }
    
    stages {
        stage('send message'){
            steps {
                script{
                    sh (script : """
                    curl -X POST \
                    -d chat_id=[챗아이디] \
                    -d parse_mode=HTML \
                    -d text="${MESSAGE}" \
                    https://api.telegram.org/bot[토큰값]]/sendMessage
                    """)
                }
            }
        }
    }
}

 

 

파이프라인에 연결 성공!

 

반응형

'DEV > Jenkins' 카테고리의 다른 글

[Jenkins] 공유 라이브러리 심화  (1) 2024.07.16
[Jenkins] 공유 라이브러리  (0) 2024.07.11
[Jenkins] Home Directory 변경하기  (0) 2024.07.10
[Jenkins] mac homebrew 이용 remove  (0) 2024.02.19
[Unity] CMD로 Build 하는 방법  (0) 2023.01.13
Comments