[Jenkins] credentials 등록 및 사용

Posted by 김성철

Jnekins - credentialsId 등록 방법

https://hongddo.tistory.com/208?category=869534  
https://hongddo.tistory.com/209?category=869534  

아래의 경로로 이동

Dashboard -> Credentials -> System ->Global credentials (unrestricted) -> Add Credentials  
  
http://localhost:7070/credentials/store/system/domain/_/newCredentials  

git 로그인 계정 정보를 추가

Add Credentials 클릭 시 정보 입력 화면에서 정보 추가  
  
Kind : Username with password 선택  
Scope : Global 선택  
Username : 깃 사용자명  
Password : 깃 비밀번호  
ID : pipeline 에서 사용할 ID  
Description : 설명  
  
ex)  
====================================================================================================  
Kind : Username with password  
Scope : Global  
Username : gitLoginId  
Password : gitLoginPassword  
ID : kimsc_git  
Description : git의 로그인 계정  
====================================================================================================  

사용방법

젠킨스에서 깃 체크아웃을 받을 때, 아래와 같이 작성해서 받으면 됨  
  
git credentialsId: 'kimsc_git', url: 'https://github.com/kkimsungchul/stock.git', branch: 'master'  
  
ex)  
====================================================================================================  
pipeline {  
	agent any  
  
	stages {  
		stage('Checkout') {  
			steps {  
				git credentialsId: 'kimsc_git', url: 'https://github.com/kkimsungchul/stock.git', branch: 'master'  
			}  
		}  
	}  
}