Tool URLs on master vs agent for pipeline jobs

18 views
Skip to first unread message

Guy Knights

unread,
Jan 22, 2018, 8:32:05 PM1/22/18
to jenkins...@googlegroups.com
I have a bit of an issue I've run into. I've set up git mirrors in separate subnets and would like my pipeline jobs to use these mirrors as the pipeline job source. Until now, we've had a central gitlab repo which we allowed access to through our firewall for each remote subnet.

I changed the url to the mirror url but hit a problem immediately. The job is started on the master, which clones/pulls the repo source in order to access the jenkinsfile. Inside the jenkinsfile is an agent definition that transfers the pipeline execution to a jenkins agent in the remote subnet. The problem is that the master accesses our local gitlab, while the agent nodes are blocked from gitlab and need to instead access the git mirror (which is on the same server, for the record).

I will probably have to add a mirror to the jenkins server so both master and agents can use a local file:// type url to access it, but I thought I'd check here first and see if there's a way to set different repo urls for the jenkins master vs the agent nodes. Is this possible?

Thanks,
Guy

Stephen Connolly

unread,
Jan 23, 2018, 1:17:52 AM1/23/18
to jenkins...@googlegroups.com
It’s all 1’s and 0’s so anything is possible... the real question is whether it is easy...

If you are using pipeline, you can override the default checkout and replace it with a checkout of the git mirror... with a NODE_NAME == ‘master’ ? “Gitlab url” : “git mirror url” expression for the repository URL.

You will need to play some dancing games to get the revision and branch to be selected if using multibranch type projects.

HTH


Thanks,
Guy

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANNH9msyOU1BWTGz%2BZnLJ%2B%3DufRupgAY1ptqF3Fa1oFodo2GcEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from my phone

Justin Vallon

unread,
Jan 26, 2018, 1:25:54 PM1/26/18
to jenkins...@googlegroups.com
git (itself) allow you to create rewrite rules that let you replace URL prefixes, for either host mapping, or shorthands:

   insteadOf = gh:

  insteadOf: https://oldhost.com/


Then: git clone gh:org/repo => https://github.com/org/repo

If Jenkins is using cmd-line git on the client, then it should observe these config settings if in $HOME/.gitconfig (config --global).



On Tue, Jan 23, 2018 at 1:17 AM, Stephen Connolly <stephen.al...@gmail.com> wrote:
On Tue 23 Jan 2018 at 01:32, Guy Knights <guy.k...@gmail.com> wrote:
I have a bit of an issue I've run into. I've set up git mirrors in separate subnets and would like my pipeline jobs to use these mirrors as the pipeline job source. Until now, we've had a central gitlab repo which we allowed access to through our firewall for each remote subnet.

I changed the url to the mirror url but hit a problem immediately. The job is started on the master, which clones/pulls the repo source in order to access the jenkinsfile. Inside the jenkinsfile is an agent definition that transfers the pipeline execution to a jenkins agent in the remote subnet. The problem is that the master accesses our local gitlab, while the agent nodes are blocked from gitlab and need to instead access the git mirror (which is on the same server, for the record).

I will probably have to add a mirror to the jenkins server so both master and agents can use a local file:// type url to access it, but I thought I'd check here first and see if there's a way to set different repo urls for the jenkins master vs the agent nodes. Is this possible?

It’s all 1’s and 0’s so anything is possible... the real question is whether it is easy...

If you are using pipeline, you can override the default checkout and replace it with a checkout of the git mirror... with a NODE_NAME == ‘master’ ? “Gitlab url” : “git mirror url” expression for the repository URL.

You will need to play some dancing games to get the revision and branch to be selected if using multibranch type projects.

HTH


Thanks,
Guy

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
--
Sent from my phone

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2BnPnMxRSDPWYopfwppn2qX9VO9Lk0PzLr9rfsXuaCEH%2BheXDw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
-Justin
Reply all
Reply to author
Forward
0 new messages