Difference between external and internal library in Jenkins pipeline - jenkins

I want to understand the difference between external and internal library in Jenkins pipeline.
I read the Extending with Shared Libraries. It says about the libraryResource step such:
A resources directory allows the libraryResource step to be used from an external library to load associated non-Groovy files. Currently this feature is not supported for internal libraries.
What do the external and internal mean? I guess that:
Internal library is gotten from a repository which is the same with a Jenkinsfile
External library is gotten from a repository which is not the same with a Jenkinsfile
Is my understanding right?
Thanks.

That line in documentation has been added a 2016, and in the same commit there is a reference to "internal" libraries being "legacy".
I have worked some time with Jenkins Pipeline now, and until now never heard of "internal" Pipelines -- I think for Pipeline Libraries as they are defined in 2022 are always "external".
Edit: Only some month before the line was added to documentation, a [JENKINS-31155] Shared libraries PR was merged to the plugin implementing Shared Libraries.
If you check the readme at that time, it tells:
Defining the internal library
An older mode of sharing code is to deploy sources to Jenkins itself. [...]
Thus:
External Library: Pushed to a SCM outside Jenkins.
Internal library: Pushed to a Git Repo within Jenkins. (Legacy, not supported anymore)

Related

Trouble With Referencing Shared Libraries in Jenkins Pipeline

We are attempting to reference a shared library in Jenkins in a pipeline using the syntax described here with #branch_name syntax. We have the "Allow Default Version to be overwridden" setting set. Yet, the pipeline ignores changes in the branch, and uses the version of the library in master. Any advice on additional settings/configuration needed or suggestions to make this work are appreciated.
We tried this syntax specifically: #Library('library_name#feature_branch_name')
Additionally, I specifically see an entry in the console output: "Loading library library_name#feature_branch_name". Yet, somehow it ignores the changes that have been commit in that branch, instead running against master.

How do I add external files to a Jenkins job?

I'm working with Jenkins to make a build of a Visual Studio C++ project I have in a git repository. However, although I don't upload them to github, my project needs SDL2's external libraries and DLL as well as some assets.
How can I add them to my jenkins job to generate a build of my project? I want to add the SDL2's libs and DLL as well as my assets folder and place them in the job workspace, in a way that won't make me upload the files everytime jenkins builds my project. But I haven't found anything that clears that for me.
Thanks!!
If your project needs assets (something like pixel art), this should probably be uploaded to GitHub along with your code. Another option is to uploaded assets to some other public/private repository that Jenkins can access.
As for the SDL2 libraries and DLL, you are correct that this should not be uploaded to GitHub. Instead, I would recommend using something like Docker to package your C++ project with its dependencies. Manually installing them on the Jenkins server is also an option, but not ideal because you'll have to do this on any machine you want your code to run.
Hope that gives you somewhere to start!

my jenkins have to build a .net service, but has a dependency library file in other repository, so how to use library when jenkins build

I use gitlab and jenkins.
Here is my structure:
branch: master
Inside the app_folder I have the following files:
app_folder
solution_folder
core_library
other services
3rd party dll
services_folder
service1_folder
service2_folder
service3_folder
service_sln
All three services use same services_sln file.
Now these services use the core libraries in the other directory which was mentioned above.
How do I configure the jenkins build?
Jenkins doesn't build your project. In order for jenkins to build successfully, your project should have the right configuration done in the solution file. With your problem statement, the project will not even build locally.
So get your basics right first

OpenShift S2I build strategy from multiple data sources

A web application typically consists of code, config and data. Code can often be made open source on GitHub. But per-instance config and data may contain secretes therefore are inappropriate be saved in GH. Data can be imported to a persistent storage so disregard for now.
Assuming the configs are file based and are saved in another private secured SVN repo, in order to deploy the web app to OpenShift and implement CI, I need to merge config files with code prior to running build scripts. In addition, the build strategy should support GH webhooks for automated build.
My questions are, to be more specific:
Does OS BuildConfig support multiple data sources, especially from svn?
If not, how to deploy such web app to OS?
The solution I came up with so far:
Instead of relying on OS for CI, use Jenkin instead.
Merge config files with code using Jenkins.
Instead of using Git source type in BuildConfig, use binary source instead
Let jenkins run
oc start-build --from-dir=<directory>
where <directory> contains merged code/config

Maven repositories

We are using maven in the development process. Maven provides a nice feature of configuring the repositories. Using this feature I have created a remote internal repository and I can download the dependencies from that repository.
The development machines are pointing to this remote internal repository. Each development machine has its own local repository(~/.m2/repository/) and hence the dependencies of the project are downloaded from the remote internal repositor**y to the **local repository(~/.m2/repository/) on each developer machine.
Is there any way that the local repository(~/.m2/repository/) on developer machines can be set to the internal remote repository that we have created and which is used for downloading the dependencies from.
If take a look on Maven Introduction to Repositories first paragraph says:
There are strictly only two types of repositories: local and remote.
There is no way how you could change this behavior.
If you would handle that differently it would cause many problems. E.g. build would take much longer because of downloading file all files, IDE would work not work properly (project dependencies would not be stored local), ...
May I suggest another approach to share dependencies and artifacts. In our projects we use nexus as a proxy and repository for our artifacts. It works well with no issues. A basic configuration I already posted here.
After nexus is running you could also setup continous integration using jenkins and enjoy a fully automated environment.
Is your requirement to avoid each developer from having to download all dependencies to his local repository?
Assuming your remote internal repository has the same format as a maven local repository, you can achieve this by adding the following line in the settings.xml of all your developers.
<localRepository>shared-drive-location-of-remote-repository</localRepository>

Resources