Understanding Jenkins plugins and agent - jenkins

I was trying to understand jenkins agents. This page asks to first create jenkins docker agent. But it doesnt say where to execute these steps?
Q1. Should we be executing these steps on node or a machine which we want to designate as agent?
The next step asks to setup an agent through Jenkins UI:
Q2. Above is nothing but the Jenkins controller UI right?
But above UI does not seem to accept IP address of the agent node on which we staarted docker agent.
Q3. Does Jenkins controller automatically discovers running agents reachable on the network?
Q4. What are exactly Jenkins plugins in relation with agents? Jenkin glossary defines plugin as "an extension to Jenkins functionality provided separately from Jenkins Core." But that does not explain much of its nature or functionality. This page also explain plugin installation and management on the controller, but doesnt explain exact nature of their functionality.
Q4.1. Do plugins run jobs of agent nodes? For example, does Android Emulator plugin installed on controller installs and runs android emulator on available agent?
Q4.2. If yes is the answer to Q4.1, does every plugin need corresponding process to be installed on the agent so that agent can carry out functionality specified in the pluin on the controller?
PS: Am a noob in Jenkins and overall DevOps stuff and just trying to wrap my head around Jenkins

Related

Jenkins - How to install a setup of plugins on an agent if I want a slave to do a specific task

In Jenkins, I'm trying to setup Controller and Agent nodes.
I've two questions here.
I want to understand how to install a setup of plugins on an agent?
2 Can I have different agent with different plugins so that I can assign a agent(based on the plugins installed) for a specific build?
Did you figure this out?
Plugins are installed on master, but jobs steps invoke the plugin on the agent (slave) where run. You can have many agents, but for example if you run a job invoking a windows batch cmd on a linux node, job will just fail.
Use labels on the nodes and your jobs to restrict where a job can run. Search http://plugins.jenkins.io for "label" for some helpful plugins to manage labels. Prefer capability/feature labels instead of tying to hostnames.
Generally, a plugin has a global configuration, and job specific parameters to configure. Not likely to have node by node plugin config but would be plugin specific in any case

Jenkins and gitlab sharing build slaves

Let's say you have a gitlab instance and it already uses Jenkins for all its CI builds via the gitlab Jenkins plugin, etc. The Jenkins setup has a modest collection of build slaves providing a variety of platforms, etc. and each slave is set up to run just one job at a time (i.e. a Jenkins job gets exclusive access to the build slave, which is important for reasons I won't go into here).
Now let's say you want to consider using gitlab's own native CI support, moving one or more projects over to gitlab instead of Jenkins. The gitlab CI would need to use the same set of build slaves, but it needs to play nice with Jenkins and the two need to cooperate so that if one runs a job on a particular slave, the other won't submit a job to that same slave until the first finishes. In effect, while Jenkins is running a job on a slave, gitlab should see that slave as unavailable and vice versa.
Anyone have working methods for getting gitlab to tell Jenkins it is using a slave while it runs a CI job on there and vice versa? The method doesn't have to be 100% bullet proof, it would potentially be okay if both gitlab and Jenkins run a job on the same slave at the same time if it is a rare event (i.e. race conditions could potentially be tolerated if the frequency of occurrence is likely to be low).
Additional info:
Build slaves include Linux, Windows and Apple.
Docker is not used and would not be permitted at this time.
We have full admin access to everything, but changing code in gitlab or Jenkins themselves would be rejected. Adding scripts or plugins would be okay.

Is it possible to integrate SonarQube, Jenkins and GitLab (all in dockers)?

Currently, I am working in a quality process so as to ensure that the code is acceptable. For that, I'm integrating Jenkins, SonarQube and GitLab, which are running in different servers (actually they are in different docker containers).
The idea is to check with SonarQube everytime the code is pushed against GitLab and block commits, merges, and so on, whether SonarQube has not passed.
I have already integrated Jenkins with SonarQube, but Jenkins checks the code inside his workspace, so imagine a situation where a developer in his laptop needs to push his changes.
My conceptual question is simple: Is it possible to integrate these technologies in order to do this? And, if the question is yes, which steps are necessary?
PD: I don't need to see code, configuration files,and so on. I just need something like:
Configure SonarQube to work with Jenkins
Do an script so as to copy that file in that folder,
...
First, in docker means each tool is in its own container.
They only need to see each other through the network, which is where a Docker Engine in Swarm mode comes in.
Second "configure Jenkins to work with SonarQube"... that is what I have done in my shop, and there isn't much to it.
Once the Jenkins SonarQube plugin is installed, and the address for the SonarQube server entered, you can configure your job and call sonar (for instance with maven: $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL)
The analysis done in the Jenkins workspace will then be published in the SonarQube server.
A swarm server is the more modern version of this 2015 docker-compose.yml file from the marcelbirkner/docker-ci-tool-stack project.
The idea remains the same though: each element is isolated in its own container.
I haven't tried It myself but https://gitlab.talanlabs.com/gabriel-allaigre/sonar-gitlab-plugin could be interesting in your setup.

Can I poll a workspace repository that is located in the slave (Jenkins+RTC plugin)?

I recently started working in a way for speeding up the building time of a relatively big software code base of my company. This code base is using RTC for source code management and after looking and trying I ended using jenkins for automation of the process. I started by creating my build server in a local machine and configure the repository through the RTC plugin, which works quite well using the poll SCM option and with the workspace repository-rtc option. However, I have to move this job to the official jenkins company server, but keeping the job execution in the original local PC. I have added the PC as a jenkins node and I have not had any problem with reaching it through jenkins, but my question/assumptions are the following:
It looks like the job is executing the RTC buildtoolkit from the slave (or at least I had to configured the RTC path in the node.
For some reason, it looks like the polling in jenkins is always looking for the repository in the master, even when I add a SCM pre step in which I can validate that the job is running in the slave system.
My question: Is there any way of ensuring the polling happening in the slave (without scripting or adding external solutions, just using RTC plugin)? For security reason I cannot add additional plugins to jenkins or to create anything in the master, I only got a free job to configure.
Thanks.

Defining executables for a slave on Jenkins

I am very new to CI systems like Jenkins.
I have a master Jenkins server running on Ubuntu. I have one Ubuntu slave (managed over SSH) ,which is dedicated to Android builds, having Android SDK and others already available.
My question is how I can tell the Jenkins master the path of android SDK on the slave server?
Go to Manage Jenkins -> Manage Nodes, and open configuration page for the slave node. Add environment variables, which will then be given only to that slave.
If you define environment variables which are used by default by the SDK, then this is enough. Otherwise you will also have to edit the job to use these (I mean, like in execute shell script build steps).
I'm not familiar with the Andriod SDK specifically, but could you pass it as a parameter to the build?

Resources