GitLab CI/CD pipeline not ran after committing to SVN

Hi,

I’m using
GitLab 12.10.3-ee
SubGit version 3.3.9 (‘Bobique’) build #4351

I’ve setup a mirror that seems to work correctly.
When I push to git, a GitLab CI/CD pipeline is correctly ran.
However, when I commit some changes to the SVN side, the git repository is correctly updated, but no CI/CD pipeline is ran.
Is that normal?

I’ve attached my logs.
logs.tar.gz (258.6 KB)

Hi Julien,

most probably this happens because GitLab started to migrate their hooks to Gitaly, which is not yet supported by SubGit. A possible workaround it to trigger pipelines through API calls adding the to the user-post-receive SubGit hook. By default SubGit doesn’t trigger this hook, to change this add the following setting to the SubGit configuration file:

[svn]
    …
    triggerSvnPostReceive = true

Run ‘subgit install’ against this repository to apply the new setting (otherwise it won’t be applied).

Ok thanks!

EDIT: Here is the script that I used, in case it is of interest for anyone 🙂

/path/to/repo.git/custom_hooks/user-post-receive

#!/bin/bash

token='<gitlab-access-token>'
id='<project-id>'

while read -a args; do
        curl --request POST --header "PRIVATE-TOKEN: ${token}" http://localhost/api/v4/projects/${id}/pipeline?ref=${args[2]}
done
1 Like

Hi @ildar.khusainov,

Do you know how I could modify this so it only runs for commits on the SVN side? In the current state, it also run for git pushes and my pipeline is ran twice.

Thanks

Hi Julien,

indeed, the hook is being triggered either if a revision comes from SVN or a push comes from Git. It is possible to distinguish those to cases by checking SVN_LAST_FETCHED_REVISION environment variable, SubGit adds an imported revision number to it. So if the variable is defined and contains revision number, then it’s a change from SVN, otherwise it’s Git push.

Hope it will help.

1 Like

Perfect, thanks!