Program Club

Jenkins 빌드에서 업데이트되지 않는 Git 하위 모듈

proclub 2020. 11. 3. 19:28
반응형

Jenkins 빌드에서 업데이트되지 않는 Git 하위 모듈


Jenkins의 프로젝트에 하위 모듈이 있습니다. 하위 모듈을 재귀 적으로 업데이트하는 고급 설정을 활성화했습니다.

빌드를 실행하면 작업 공간에 하위 모듈의 파일이 있음을 알 수 있습니다. 문제는 서브 모듈의 첫 번째 개정판 인 것 같습니다. 변경 사항을 푸시 할 때 (GitHub에 호스팅 된 저장소) Jenkins가 올바른 변경 사항을 가져 오기 위해 하위 모듈을 업데이트하지 않는 것 같습니다. 본 사람이 있습니까?


있습니다 2.0 플러그인 젠킨스 힘내 서브 모듈의 적절한 업데이트를 확인해야하는 "사전 서브 모듈의 행동을"해야합니다 :

자식 2.0

으로 주석 에 의해 vikramvi:

Advanced sub-modules behavior> " Path of the reference repo to use during submodule update"이 필드에 대해 하위 모듈 git url을 추가하십시오.

통로


Owen B댓글에서 다음 과 같이 언급합니다 .

인증 문제의 경우 "상위 저장소의 기본 원격에서 자격 증명 사용"옵션이 있습니다.

여기 JENKINS-20941 에서 본 :

https://issues.jenkins-ci.org/secure/attachment/33245/Screen%20Shot%202016-07-08%20at%2010.09.17.png


이는 Jenkins 사이트의 Recursive submodules 섹션 아래에있는 Git Plugin 문서에서 다룹니다 .

발췌

GIT 플러그인은 하위 모듈 자체가있는 하위 모듈이있는 저장소를 지원합니다. 그래도 켜야합니다 : 작업 구성 -> 섹션 소스 코드 관리 , Git- > 고급 버튼 (빌드 할 분기 아래)-> 하위 모듈을 재귀 적으로 업데이트 합니다.

작업 구성 화면의 소스 코드 관리 섹션에서 추가 버튼을 아래로 당겨 "고급 하위 모듈 동작"을 선택합니다.

   s1

                                 s2

그런 다음 "재귀 적으로 하위 모듈 업데이트"를 선택합니다.

   s3


Git 저장소가 항상 하위 모듈 의 특정 개정판참조한다는 것을 알고 있습니까? Jenkins는 개정판을 자동으로 변경하지 않습니다.

새 버전의 하위 모듈을 사용하려면 로컬 Git 저장소에서 다음을 수행해야합니다.

cd submoduledir
git pull
cd ..
git add submoduledir
git commit -m 'Updated to latest revision of submoduledir'
git push # Go and watch Jenkins build with the new revision of the submodule

이렇게하면 Jenkins는 빌드하는 동안 서브 모듈의 똑같은 개정판을 확인합니다. Jenkins는 사용할 하위 모듈의 개정판을 자체적으로 결정하지 않습니다. 이것이 Git 서브 모듈과 SVN 외부의 근본적인 차이점입니다.

You might want to read a good reference on submodules, e.g. http://progit.org/book/ch6-6.html.


Finally stumbled on a way to do this and it's simple.

The Issue:

The initial clone with credentials works fine but subsequent submodule cloning fails with incorrect credentials.

  1. Automatic advanced sub-module cloning: Source Code Management >> Additional Behaviours >> Advanced sub-modules behaviours: results in credential error.
  2. git submodule update --init in the Execute Shell section also fails with credentials error.

The Solution:

I'm using jenkins-1.574.

  1. Check the Build Environment >> SSH Agent box.
  2. Select the correct credentials (probably the same as selected in Source Code Management section
  3. Update submodules in the Execute Shell section

    git submodule sync
    git submodule update --init --recursive
    

Here's a screen shot여기에 이미지 설명 입력


It looks like I found a solution:

I added a build step to execute the following shell commands:

git submodule foreach git checkout master
git submodule foreach git pull

Jenkins Git 모듈을 사용하는 경우 "Wipe out workspace before build"로 설정할 수 있습니다. 이렇게하면 항상 올바른 하위 모듈을 가져옵니다.

참고 URL : https://stackoverflow.com/questions/9953299/git-submodules-not-updating-in-jenkins-build

반응형