1

I need assistance with triggering a Jenkins Pipeline Job whenever specific branch/tags are changed in a GitLab repository. However, I am unable to access Jenkins externally, as there are no open ports or webhooks available.

Initially, I attempted to have Jenkins periodically check the repository for changes and filter them based on tags within the Jenkinsfile. However, I observed that I do not receive any environment variables from the GitLab plugin unless the trigger originates from GitLab itself.

My primary question is whether it's possible to install a GitLab Runner on the same machine as Jenkins and use it to trigger a Jenkins build?

Thank you for your help.

Büni
  • 23
  • 4

1 Answers1

1

If the runner and the Jenkins instance are running on the same machine, it may be possible to use localhost to trigger the build. You need to first enable the build to be triggered with the Jenkins API. Then, when the GitLab build is running in the runner, you can call the API endpoint (using curl, for instance) to trigger the Jenkins job. So assuming that your Jenkins instance is running on port 8080, you should call the API with 127.0.0.1:8080/job/<jobname>/build?token=<token>". Since localhost of both runner and Jenkins are the same, the endpoint can be reached.

In fact, even if the two were in different machines within the same intranet, they would be able to access each other.

M B
  • 2,700
  • 2
  • 15
  • 20