Jenkins : bring the node online/offline automatically - jenkins

I want to bring my node online/offline automatically in Jenkins but I dont know how to do. I know cron conf for slave is possible but i can't use it because we have a global policy on this setting. So is there a way to bring node online/offline automatically in Jenkins please
I need it because I need to run a pipeline on specific slave which is offline in major of time ;)

Related

Make Jenkins node offline if job passes

Is there any script or plugin so that I can take Jenkins node offline automatically if the job passes.
Or if i explicitly give choice parameter to take node offline after current build.
I mentioned before an API for disconnecting a node: see more at "Monitor and Restart Offline Slaves".
That means you can add a post-build action, which would call this api though curl.

Functionality to start and stop jobs

I am not sure something like Jenkins is built for this functionality, but I am curious if it is possible.
Say I have some sort of code, that I want to run from 7am until 7pm. Typically Jenkins jobs are done when whatever process is complete. Like a python script closing.
my goal would be to be able to have a script that will infinetly run, and will be terminated by Jenkins at a certain time. Doing this would still allow me to see the nice web ui, remotely start it, easily add hooks, etc.
Is this possible in Jenkins, or is there another platform like Jenkins that supports this type of functionality. Basically instead of using Jenkins for 'builds', you would be using them to control services
I have completely replaced Linux Cron with Jenkins, so yeah you can do what you're wanting to do. Only limited by your imagination :)
I have all of my Linux servers configured as nodes (via ssh) within Jenkins, and the connecting account on each of them has sudo privileges, so I can essentially have Jenkins do anything I want it to, at the OS level.

Post commit deliver hook for RTC

I have a working Jenkins setup that can pull source code from RTC (Jazz server) and build etc. I can run this Jenkins job on demand or schedule to run at a random interval. However, now I am exploring as to how I can run this job only on detecting a change in the repository (e.g. new change set is delivered). I dont want to use the polling mechanism that Jenkins provide and I want RTC's post commit process to call my Jenkins job remotely.
Please can anyone guide me how I do it? Thank you.,

How to set default value for label expression in Jenkins project configure page

currently I got a request that I need to block all build jobs in Jenkins master, every jobs must be built in slaves.
So I would like to configure every new job in Jenkins will be default checked in "Restricted where this project can run", and then a default value for Label Expression, e.g. "docker-slave". So that everytime dev create a new job, they don't have to choose which jenkins slave will be used (actually they don't want to do it).
I would like this to be default for every new job <-
Any help would be appreciated. Thanks a lot.
Here are two ways:
Under the master node configuration, you can specify to exclusively run jobs that are bound to the master. If none is bound, none is run. This means, the one writing jobs has to explicitly bind the job to master.
There is a job restrictions plugin that allows finer control over what can run on each node. You could allow to run jobs on master only from a specific user.

jenkins slave runs as user

I have a jenkins setup with multiple users which are logging in with Active Directory plugin. This is useful so that each user can access his own tasks.
However each user also has different permissions on the local network, such as access to different folders etc. I have noticed that the permissions given to each task is not linked to the user but to the account under which the slave is running as service. Is there a way to change that so that the task is executed on the slave under the credential (and hence permissions) of the user?
Thank you
The problem is: there is only one slave process running the different job assigned to that server by the Jenkins master.
So the slave itself runs as one user (generally, a dedicated account or a system account).
Since you can get the user id as environment variable (with a plugin like JENKINS Build User Vars Plugin), you might consider configuring the job in order for it build step to "run as" the user who triggered the build.
See for instance the JENKINS Authorize Project plugin.
However, as mentioned this answer:
The "Authorize Project" plugin does not change the OS level user that is running commands.
It only sets the Jenkins user that is running the job and any downstream jobs, using Jenkins authentication (whatever it might be).
So you are left with build step with runas or su -c commands in order to be sure that your task does run with the right user.
I had the similar issue and I can recall for managing more control on projects I used role strategy plugin and setup global security using LDAP servers (Active directory should also be ok).
And I used authorized project plugin.
Have a look and I hope it should solve your purpose. Let me know on comment section for any clarification.
you can partially fix your problem this way:
install the slave as a service using the Java Web Start method and JLNP
go to Services control panel in windows
under Properties -> Connection replace the local system connection with a specific user
rebooted the service
This at least gives you the ability to use one account instead of system.

Resources