Trigger Jenkins job on change of directory content - deployment

Below is the problem,
There is a directory,Lets called is user/mydir
Is it possible to trigger a jenkins job on any change to this direcory (eg:copy a file , delete a file ,create a file in the directory).
Any feedback will be really helpful.

You can use the FSTrigger Plugin to do that.

Related

How to perform a filewatch in kubernetes

We need to perform a file watch on a container and trigger a script once the file is available.
Anyone who have come across this kind of requirement pls assist.
Thankyou
We use a https://hub.docker.com/r/weaveworks/watch/ container as a side car to watch for changes in a file and then trigger a reload of a process when a config file changes.
The README says Watches for changes in a directory tree... so this should also trigger an event when a new file is created and you should be able to use this for your purposes.

How to access the generated File by jenkins server through URL?

I am using jenkins.
In Each build I execute from Jenkins I am storing a build number in a Test file called Build.txt
Which is in opt/jenkins/ path.
I want to access this file through an URL from a browser.
Is it possible and How can I achieve it?
you can artifact the build files using
Post build -> Archieve artifacts
you can see those archieved files in URL using below plugin
https://wiki.jenkins-ci.org/display/JENKINS/Archived+Artifact+Url+Viewer+PlugIn
The solution is to use Jenkins userContent directory. Jenkins has a mechanism known as "User Content", where administrators can place files inside $JENKINS_HOME/userContent, and these files are served from http://yourhost/jenkins/userContent.
Make sure your jenkins have Copy To Slave Plugin installed.
In your job config page, Add Post-build Action-->Copy files back to the job's workspace on the master node.
In the Files to copy field, fill in the files that you want to copy from the slave node back to the jenkins master's corresponding workspace of current job.
Goto your $JENKINS_HOME/userContent folder, create a link to $JENKINS_HOME/jobs/yourjob/workspace/screenshot by issuing command for example:
ln -s screenshot /home/ci/jenkins/jobs/tc_ui_test/workspace/screenshot/
After that, you can access your contents from url: http://yourhost/jenkins/userContent/screenshot

TeamCity, how to get names of the files edited

I am using TeamCity and I am new to it. I have added a Build Configuration to the TeamCity and I created one VCS root to attach to it.
However, my project have a special requirement to detect a particular file that was changed in the VCS root location and use that file in build step. I am sure this could be done in TeamCity, I am not able to figure out how.
Any help? Thanks,
To get the names of the files changed this is what I did. Thanks to Sam Jones.
I used System.TeamCity.build.changedFiles.file variable as follows.
Add a command line build step
Select Run as Custom Script
Add the script copy "%system.teamcity.build.changedFiles.file%" changelog.txt in script box.
You will get the changes in changelog.txt file in the format specified on this link.
NOTE: teamcity.build.changedFiles.file does not work. You need to use system.teamcity.build.changedFiles.file
It sounds like you want a VCS Trigger that specifies VCS Trigger Rules, so that a build configuration will run when someone makes a change to a particular file. The documentation has some nice examples of how to do this. If you're trying to trigger a build on one particular file, try this:
+:foo/bar.txt
This excludes all files from the trigger rule and then includes bar.txt in the foo directory. Paths are relative to the root of the repository (do not include a preceding slash). If someone modifies foo/bar.txt, the build configuration will be triggered to run.
VCS Trigger Rules also support pattern matching and all sorts of other options. Check out the documentation.

cloudbees folder plugin jobs in copied folders must be saved before they can be run

I'm having a look at the Cloudbees Jenkins Folder Plugin. It looks like it will serve my purposes in allowing me to easily copy groups of jobs but...
When I copy a folder containing some jobs I have to click through Configure / Save for each job in the new folder before the Build option is available. Is this expected behavior?
thanks
Glenn
Yes, when a job is copied it is marked temporarily unbuildable until you save its configuration. This is essential in case the origin job was configured with a build trigger (like building on a schedule): you would not want the copied job to start running until you had a chance to check its configuration and perhaps make changes.

Creating Hudson jobs and views from command line

Can I create Hudson jobs from the command line?? If yes, can views be created the same way??
You can try the Hudson Remote API, which include an API to create Jobs.
You can always create the xml file for the job. The location will be a new folder in the jobs directory. Than you only need to trigger a reload of the config. It should be similar for the views.