Jenkins gerrit trigger not fetching my change while building

后端 未结 4 2028
半阙折子戏
半阙折子戏 2021-02-07 14:48

I have configured jenkins with gerrit trigger plugin to validate every commit we push to gerrit. I am expecting this trigger to include my latest change with original repo and m

4条回答
  •  孤独总比滥情好
    2021-02-07 15:45

    Using Jenkins 1.532.2 Git Client Plugin 1.6.2 Git Plugin 2.0.1 Git Trigger 2.11.0

    Here are the steps for configuring the Gerrit Trigger (from memory, hopefully all works fine):

    1. Install the plugin(s) "Gerrit Trigger", "Git Plugin" and "Git Client Plugin"
    2. In the main jenkins config (HOME->Manage Jenkins), click on Gerrit Trigger.
    3. Create the server and configure it. Use "Test Connection" to be sure it works.
    4. At the end, under "Control" press "start" (No idea what that does or if it's actually needed, but I did that).
    5. Go to your project's config (MYPROJECT->Configure)
    6. Check "Gerrit event" under "Build Triggers"
    7. In the newly added menu, select your server, your triggers, etc.
    8. For Gerrit Project I used "Plain" with "MYPROJECT" as pattern
    9. For Branch, I used "Path" and "**" as pattern (builds all branches)
    10. Under "Source Code Management" (up from triggers in my UI), click on "Git"
    11. Set the Repository URL, here $USER matches for me, but otherwise write the correct user $GERRIT_SCHEME://$USER@$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT
    12. Specify a branch: $GERRIT_BRANCH
    13. Under "Repositories" on the right, click Advanced, for "Refspec" enter $GERRIT_REFSPEC
    14. Click Add right below, and select "Strategy for choosing what to build"
    15. Select "Gerrit Trigger"

    Not very intuitive but it should work. I suggest making sure the correct SHA1 Ids are being built.

    If run into Error stderr: fatal: Couldn't find remote ref $GERRIT_REFSPEC

提交回复
热议问题