How I can upload files in my userContent of jenkins? - jenkins

I'm new in Jenkins, I want to upload a file from my local disk or from a Github repository in my userContent and be able to use it in a dsl job, so that it reads that file and can create 2 jobs. I have the code to create the 2 jobs but the problem is that I need to do it from a .groovy, .sh or whatever file.
Thank you!

I resolve it! In the folder jenkins_home/userContent/ from my computer.

Related

Adding groovy file from workspace for seed job

I have a seed job in Jenkins to create a job to build the workspace. I want to add the job groovy file from the repository. How do I specify the file path for the grooovy on the seed job build step?
I am trying to add it from the file system on the configuration. I get the error file not found. I have tried adding the complete path and also the name of the file.
I have found the solution for it.
You can specify just the relative path to the workspace to access the groovy files.

Can JENKINS create build by excluding particular files?

I am actually trying to ignore a particular file to be included in the build. Actually it is a thumb.db file which is automatically created whenever images are encountered in a folder. My solution contains the image folder. So basically, whenever the build is triggered from JENKINS, it will create the thumb.db file.
Is there any way, I can ignore the Thumb.db file from getting created via JENKINS?
I can switch off the thumb.db file from creation by switching it off from my windows, but I have to do it every time a build is created from JENKINS. So I want to ignore the thumb.db file from creation.
Below is the Job creation flow in my JENKINS from my current project:
SCM
I have used the Team Foundation Server Plugin and have mentioned my SERVER URL and PROJECT PATH
POST BUILD steps simply create the build to the staging location(folder Location)
Any help is appreciated.
Thanks,
AFAIK, on windows you can turn it off or on for the whole system and not for particular folders.
So you have to choose. On or off.
If you still want to keep it on, you'l have to handle this in your Jenkins build scripts. Remove any thumbs.db files after build is done.
If your output is an archive, make sure to exclude thumbs.db from it. All archives support an exclude flag.
I hope this helps.

How Jenkins can copy new file from given folder

I'm new to Jenkins. I have given remote path to folder with already builded setups inside - filenames can vary. I need to monitor that folder for new file and copy it to my workspace (and then deploy and execute some auto tests against them).
Question is how to recognize that I have a new file (this will be my trigger to start whole process) and how to store that new file filename in variable - to copy it later?
Is that even possible in Jenkins? Maybe it is a plugin for that already?
Jenkins is working on windows machine.
Thanks in advance.
One possible solution would be to use the filesystem scm plugin and set up source polling to trigger your job.
https://wiki.jenkins-ci.org/display/JENKINS/File+System+SCM
Of course that doesn't solve the issue of what the new file is. If you are using powershell a good solution is here: Powershell Get-ChildItem most recent file in directory

Package the result of a build in Jenkins into a zip

I've just started using Jenkins and need some advice.
After a successful build I would like to have the resulting directory packaged into a zip file and stored in workspace so later I can send to Artifactory.
At the moment I'm using a program that I wrote for that purpose which I run in a batch file as the last step of a build, but I wonder if there is a way of having Jenkins do that.
The file operations plugin has a zip operation.
Used with ${GIT_BRANCH} to create a zip file of the successful build.
https://wiki.jenkins.io/display/JENKINS/File+Operations+Plugin
I you use a pipeline job (wheter that's declarative or scripted) you can use the zipFile step and give it the directory path that you want to be zipped.
https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#zip-create-zip-file

Downloading Nexus artifacts to Jenkins Job workspace

I have an use case where I need to download selected jar files from nexus repository to a Jenkins job workspace and run a program over the downloaded jar files. (I Want to use the .class files in the jars)
Is there any Jenkins plugin available for this?
Add a build-step in the job, prior to the one doing the actual work
and use a copy (or ftp) command to get the files.
You could try the groovy plugin and embed a script within your Jenkins job

Resources