Git Jenkins Checkout authentication failed : ERROR: Error fetching remote repo 'origin'
Gitea & Jenkins CI/CD 에서 Pipeline을 작성하며 테스트 도중 repo Checkout 과정에서 에러를 마주하게 되었다.
ERROR: Error fetching remote repo 'origin'
build console의 에러로그를 확인해보니 인증 실패가 떴다...
혹여나 필자와 같은 상황이라면 이 글의 끝에 해결법을 찾을 수 있을 것이다 =)
분명 Jenkins에 Gitea 연동 설정에 있어 Credential을 넣어주었는데?????????????
우선 필자는 Credential 설정이 잘못된건가 라는 생각에 Jenkinsfile 과 Jenkins 서버의 프로젝트 Gitea 설정을 확인해보았다.
pipeline {
agent any
stages {
stage('gitea clone') {
steps {
echo 'Clonning Repository'
git branch: '{branch name}',
credentialsId: '{Credential Token}',
url: '{git repository URL}'
}
}
}
}
현재 Jenkins Credentials의 kind는 username&password로 잡혀 있고 Prac_Jenkins_CI_CD repo는 private이기 때문에 credentials가 맞을 경우에만 해당 repo를 Branch Source에서 확인할 수 있다. 그럼 Credentials는 올바르게 작동을 하고 있다는 뜻이다.
어디가 문제인지 찾다 혹시나 해서 username&password 가 아닌 personal access token만 인증이 되는건가 라는 생각에 시도를 해보았다.
우선 Gitea에서 Access token을 발급받고 이를 Jenkins서버의 Credentials의 kind 를 Gitea personal access token으로 해주어 등록을 해주었고 프로젝트 설정의 credentials와 Jenkinsfile의 crendentials 부분도 바꾸어주었다.
결과는 다시 실패....
구글링을 하다보니 credentials의 kind를 username&password로 하고
username= gitea Id (Github 또는 Gitea 등 로그인시 ID)
password= personal accessToken (Github또는 Gitea 등 자신이 사용하는 형상관리 tool 에서 access token 발급)
위와 같이 등록하고 진행하면 성공을 하는 사례를 확인하였고 다시 시도를 해보았다...
성공
???!??!??!??
만약 필자와 같은 상황이라면 위의 방법을 시도해보길 바랍니다 ! *^^*
(참고글)
[Jenkins] Git과 연동하기
목차 1. 연동하기 2. git webhook 설정하기 (push가 일어나면 Jenkins 자동 build 되게 하기) Jenkins와 Git 연동하기 1. Item 생성 2. Git 추가 2-1 Failed to connect to repository: Command "git.exe ls-re..
yeonyeon.tistory.com
[Jenkins] github private repository 연동하기 / Credentials 오류 날 때
[Jenkins] github private repository 연동하기 / Credentials 오류날 때 Jenkins와 github 연동하는 방법을 따라가던 중 private repository 연동하기에 자꾸 실패했다. 아무래도 Credentials 생성이 잘..
be-developer.tistory.com