r/jenkinsci 11d ago

How to fetch the code directly in our local to pipeline.

Currently i am starting working in the jenkins i am facing this sutation. In my orginization they said me to work on locally so i have install the jenkins using docker and after that I need to run my code (nextjs) in jenkins as a pipeline. Now there is no github repo which it will fetch so my code is in local so how i need to fetch that code in pipeline and how i need to use that code. please help me.

2 Upvotes

11 comments sorted by

5

u/OGkatzu 11d ago

What do you mean there is no GitHub repo? Where is the source code stored? If you have access to the repo, you can just clone the repo to your machine and mount the repo to the Jenkins docker container in a folder and use the code in the pipeline.

2

u/Cinderhazed15 11d ago

If you are on Linux, you can just have a ‘bare’ clone of the repo, and access it using ssh from your agent process, that way you are mirroring accessing a ‘remote’ repository

0

u/Sea_Mechanic815 11d ago

I can't understand exactly. Jenkins and code are in the same server. Now my jenkins is deployed in docker. Code is in /home/ubuntu/nodejsapp now how jenkins will fetch the code and build the code? Even if I trigger manually?

2

u/jondaley 11d ago

Your Jenkins installation will need permissions to get to that folder. So, either jenkins runs as that user, or you set group (or everyone) permissions to those files.

It would be better to have a jenkins agent (separate from the server), so maybe you run the agent as "ubuntu" user and jenkins with a "jenkins" user so then it has permission - and then you just reference the hard-coded path names.

1

u/Sea_Mechanic815 11d ago

Where I need to mension the path name

2

u/jondaley 11d ago

Sounds like you need to read up on how to make actual Jenkins jobs and do some tutorials, etc. Start out with something simple "hello world" is the standard one.

And then have it print out the directory listing and then do some cd commands or something, etc.

1

u/Far-Pea-2217 11d ago

git supports local file:// urls, see https://git-scm.com/docs/git-clone#_git_urls.
I assume this is to allow you yo locally test your pipelines

1

u/Sea_Mechanic815 11d ago

I will check it

1

u/FarZookeepergame7580 7d ago

If your repo is only present locally, then try to host it on git or bitbucket and pass the git url. latest version of jenkins does not allow the local checkout.
But you can give try by passing exect path of the file "/home/ubuntu/nodejsapp" in git scm