Search code examples
gitjenkinsgerritgearmanopenstack-zuul

How to process a git submodule's parent repo with zuul, Gearman and Jenkins?


Following tools are used:

  • Gerrit
  • Openstack/Zuul
    • which includes Gearman
  • Jenkins (Pipeline jobs)

Project configuration:

  • Project "parent" as a git repository.
  • Project "child" as a git repository.
  • "parent" has "child" as submodule configured.
  • Zuul is configured with a Gerrit review zuul-pipeline and a Gerrit merge zuul-pipeline for both projects.

What I want to achieve is, when a review or merge build is started through the "child" project that also a build of the "parent" project with exactly that change is started. How?

I currently tinkering with following, what sadly doesn't work right now, because I can't change the url of the submodule out of the blue just for one build. Zuul configuration:

projects:
- name: parent
  review:
    - review-job

- name: child
  review:
    - review-job:
      - review-parent-with-change-of-child-job

(I've skipped the merge parts, because review is enough to explain the issue)

So because of the fact, that the typical Zuul job inside jenkins has just some $ZUUL_URL/$ZUUL_PROJECT config inside and a link to the Jenkinsfile I have to write a special job for the review of the parent with the change of the child. Which is in the end just a build of the "parent"s master branch with the submodule's change out of Zuul Merger's repository.

And there's the problem, the only way I could achieve to checkout that change from the Zuul Merger's repo is in changing the url inside .gitmodule file. That's in my opinion not a sane way to do such a build, so I am searching for an other solution. Due to the fact that the documentation about Zuul and projects having submodules is almost zero, I'm kind of stuck here.

I'll still try to achieve this the insane way (not tested yet), but would like to change that asap to a more sane and secure way, if one exists.


Solution

  • Changing the .gitmodules is basically just a NO-GO.

    But you don't need to change it! I didn't realize this at first.

    A pull of the Zuul repo is enough in your Jenkins file like this:

    sh '''
    cd path/to/your/submodule
    git pull $ZUUL_URL/$ZUUL_PROJECT +$ZUUL_REF:refs/heads/zuul
    '''
    

    And your submodule contains the change you want to test in your build.