How to trigger Jenkins job when a change is made in Server folders? - jenkins

I want to trigger my Jenkins Job when a particular folder is modified in WAS server.Is there any plugin available ? I tried with 'FSTrigger' plugin but it is working only for local machine folder changes but not for server side changes. I am getting following message in FSTrigger floder log.
Trying to monitor the folder 'https:\server_name\folder_path'
The directory 'https:\server_name\folder_path' doesn't exist.
Kindly help me on this.!!

Regarding this answer:
How to set FSTrigger's folder path in Hudson CI integration tool?
I think you can only monitor a local URL, like:
/var/www/html/test/test1/config
To solve your problem, one solution is to connect your WAS server to your Jenkins master as a Jenkins slave.
And next, create a Jenkins job using the FSTrigger plugin and launch it on your WAS slave.

Related

Jenkins pipeline Workspace got deleted automatically

We have observed that the Jenkins Pipeline Workspace project folder getting deleted. We have not configured any cleanup plugin for this as well as not configured any cleanup module in the pipeline.
This behavior is random and it's deleting Old as well as new jobs.
We can see the workspace deletion traces in /var/lib/jenkins/logs/tasks under Workspace clean-up.log. Please let me know if anybody is facing the same issue and how to fix this issue? Our Jenkins version is 2.289.2
Try disabling the workspace cleanup. There are two ways to achieve this. I was facing the same issue and I've just tried the first approach and monitoring the workspaces to see if this works.
Add -Dhudson.model.WorkspaceCleanupThread.disabled=true to the Jenkins system properties.
If Jenkins is running through terminal:
java -Dhudson.model.WorkspaceCleanupThread.disabled=true -jar jenkins.war
If Jenkins is running as a Linux service:
Stop Jenkins (service jenkins stop). You will need root privileges.
Edit the /etc/defaults/jenkins file.
Add an additional line for the JAVA_ARGS or add to it if it already exists.
JAVA_ARGS="-Dhudson.model.WorkspaceCleanupThread.disabled=true"
Start Jenkins (service jenkins start).
Disable or uninstall the Workspace Cleanup plugin. (I haven't tried this)

Jenkins build trigger configuration getting lost

I am trying to use the
Build after other projects are built
feature of Jenkins. I am using Jenkins ver 2.73.2 and whenever I go to
Configure job -> Build Triggers
and specify my projects, the configuration does not get saved. There is no save button so when I navigate to another page the configuration gets lost.
I am using JenkinsFile in all projects to build it so this is the first thing I am doing from the UI.
Couldn't find a proper solution to this issue anywhere.
Try to restart your jenkins.
Possibly you my have harmed you jenkins folder in program files.
Please try to upgrade your jenkins

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.

Jenkins- Create Jobs on different servers

I want to configure Jenkins to build my code on 1 server. Then want to deploy it on another server using Jenkins.Both servers are using Linux I want to automate the entire process as much as possible. I went through some of plugins like pipeline, Job Import Plugin, etc
Can anyone guide me how to go about it ? Which plugins will be useful ? Any example or tutorial somewhere will be useful. The configuration of build pipeline plugin on jenkins was not seamless for me.
Thanks,
Bhargav
I would work it this way :
Install jenkins on your first server
Install the following plugins : ssh credentials, ssh slaves, copy to
slave, and restart jenkins
Go to Manage jenkins -> Manage credentials, and add ssh credentials
for your second server
Go to Manage jenkins -> Manage nodes, and create a passive slave.
The launch method should be "Launch slave agents on Unix machines
via ssh". You should use the credentials that you have added in step
3
Create a job to build your code. In the advanded options of job, you
should indicate that the job must only be built on master node.
Create a job to deploy your code on the second server. In the
avanded options of job, you should indicate that the job must only
be built on slave node.
In the "Build Environment" section, check the "Copy files into workspace before building" box and configure what files you want to copy from first server (https://wiki.jenkins-ci.org/display/JENKINS/Copy+To+Slave+Plugin)
The code will be copied into the jenkins slave's workspace.

Build a project remotely but pick the code from local machine through Jenkins

I'm running jenkins on my local machine. I need to build and run a project on remote machine as a slave.
I have my project(Java code) in my local machine where the Jenkins is running. So Now when I build the project it looks for the code in my slave machine and says it's not able to find the build.xml in my slave machine.
I want to be able to have Jenkins looks for the code in my local machine and build it in my slave machine and run in the slave machine.
Is that possible? if yes pls help me.
You do not state which version control system you are using? Jenkins has version control plugins for Git, Subversion, etc...
The idea is that you commit and push your changes to your source code repository and the Jenkins slave will automatically pull down the code and compile if anything has changed.
Try the copy artifact plugin. You can create 2 jobs - 1st one to just check out the source code from your repo/version control/workspace. The second job (which runs on the slave restrict where this job can be run inside the job config) can copy those files automatically to the ...remote slave/workspace and then you do whatever you want with them.
This will do what you want, but as Mark O'Çonnor mentions, the idea is you commit the changes to your repository and then the other machine checks it out.

Resources