I am new to Jenkins server,
Take the back up of Jenkins jobs and plugins and delete the same which is older than 15days.. with shell script
Everything you need is present in your Jenkins home folder. If you want to take a backup of your job configuration, you can copy the config.xml file found inside the $JENKINS_HOME/jobs/<job_name> directory. The directory will also have a list of builds which will contain the logs of these builds, so you can take a backup of this as well if necessary. As for the plugins, you can find them in the $JENKINS_HOME/plugins folder. The .jpi and .hpi files are the plugin files.
As for deleting files older that 15 days, this article gives a pretty comprehensive method for doing it.
Related
I set a GIT_STRATEGY variable to none in a .gitlab-ci.yml file. So a repository is not built in a deployment server automatically. So we avoid building the git repository with its all history etc. A git-archive command will be used instead.
This way only needed files will be copied from a GitLab server.
Now I am looking for the way to send the bash script to the runner.
As we know, the .gitlab-ci.yml file is actually being sent to the runner. Isn't it a way to send the bash script to the runner too? Then I would make the .gitlab-ci.yml file just to start the bash script and have a job done.
Of course, I could put the commands to the yml, but there are some limitations then because of a yml syntax. I could also make the runner scp the file but this would be too complex. Any ideas?
update
Let me try to approach what I am going to achieve. There are several bash script files. Each of them is a specific scenario of the deployment. For example, one pulls project files from GitLab, deletes files in a folder public and moves project files to it.
The other script file pulls project files from GitLab, moves the files to the folder and creates a backup.
The other script file pulls project files from GitLab, moves the files, creates backups and performs a database migration. Etc.
There are three hosts:
Local PC of an administrator.
Remote GitLab server
Remote deployment server that server websites. (It has Nginx or Apache)
One of the script files will be executed on the deployment server. There is a number of the script files so we must provide replacing the script file from time to time.
The question is how to bring the script file to the deployment server so the runner could run it?
I am having issues with Jenkins that I am unable to resolve, and all the solutions I've found online I've used in the past, but are not helping.
I am on windows 2008r2, utilizing svn, jenkins version 1.407.
Initially the service failed, and was not resolved with past methods. In the past I have successfully troubleshoot Jenkins by killing hung processes, restoring the war file, ect.
I have attempted a new install with bringing over the files in the jobs folder. The end result was a partially functioning Jenkins would attempt a build it would report no change and not update.
What I'm trying to determine is a list of files/folders beyond the jobs folder that I need to move to the new install. The initial install predates me and was Hudson. The folder has a number of obviously obsolete files and folders (both a jenkins.war and a hudson.war)
Go to Jenkins home folder and collect:
all ./*.xml files in - these are configuration files for plugins and jenkins itself
users/* in case you have security enabled
subversion-credentials/** and secrets/** for any kind of keys provided in jenkins to access svn or other resources
plugins/*.*pi folder for all plugins - you don't need to have the unpacked folders
jobs/*/config.xml - to retrieve all job configurations; jobs/*/nextBuildNumber if you care to continue build numbers
plugins may create additional folders which you may want to use
with that you should recreate Jenkins as it was. Pay especially attention to config.xml file in root folder - this holds main jenkins configuration. If your issue reproduces on new system most likely a plugin is cause for problems - in that case review log files most likely you will find out which plugin causes trouble.
You didn't indicate if you tried new setup with same version of Jenkins or newer one; if you are using newest version it may be that ssh key handling / svn authentication for each job needs to be updated as somewhen in last few months authentication / security handling changed. Best is to look into Jenkins release log.
I'm using Jenkins 1.55x on CentOS installed as RPM; given that it is a webapp I assume Windows 1.4x setup is similar.
What I have done :
I have Jenkins set up on my Ubuntu in :
/var/lib/jenkins/
I have a job, that runs every 45 minutes that does a hg pull and hg update --clean default
from my bitbucket repository.So this is running fine.I have a folder
/var/lib/jenkins/jobs/Code Deployement
which contains the latest updated code from my repository.
Problem :
However, I want to access my updated code from
/var/www/html/[project-name]
Query :
Is there anyway i can make jenkins job update this folder instead of the /var/lib/jenkins/Code Deployment folder ? I certainly dont want to make /var/www/html/[project-name] as my jenkins home folder.
How can I achieve what I described above.Will I have to copy the folder from the jobs folder to my desired location after every time the job runs ? Please help me out with the solution,I'am a beginner with automated deployment using Jenkins.
Thank you.
Under "Advanced" you can explicitly choose a working directory for the projects without changing the Jenkins home directory. Check the "Use custom workspace" box and set the directory that Jenkins will pull the code to and build in.
In our setup we wait for the build process to complete in the working directory and add a build step for Jenkins to copy (most) of the files out to the directory that serves up the website. We had issues with file locking preventing the build process if someone (e.g. the testers) were using the site.
One simple way to do it is to create a symlink under /var/www/html/ that points to your code directory, e.g.:
sudo ln -s /var/lib/jenkins/jobs/"Code Deployement" /var/www/html/[project-name]
I use maven project and run it using Jenkins
Have problem with filepath: I write some info from one job to the file that is in the root directory of the project. Then I run another job and I need to take the info from that created file. But I can't get it, file, opened from the second job is empty.
Please help me to fix this problem
Thanks
The workspace directory for a Jenkins job is ephemeral, i.e. it gets deleted and rewritten when you run a new build of the job. If you want to save a file from one job for consumption by another, use Jenkins' artifact archiving feature; here's a blog post that explains everything.
I have the following sample / test configuration that has Hudson create a directory of empty folders. Its then instructed to archive everything within that folder, except it will not match empty folders and ends up archiving nothing. Whats more annoying is that Hudson does not alert you that nothing matches the search string "root**", but when it builds, it says nothing matches the search string.
(source: 86th.org)
We need Hudson to archive these empty folders for our installer since its expecting them. I fear this may not be possible because of the text "Files to archive".
At any rate, How can I configure Hudson to archive empty folders as an artifact.
You should create the artifact that you want in your build scripts, and then have hudson archive that file. So if you want a zip file that contains empty folders, do the appripriate zip command in your batch file or ant script. Then archive the output file.
Looking at the Hudson source code, it seems as if artifact archiving is meant to only match against files.
You might want to file a feature request or send an email to the USERS list, the Hudson team is pretty good about replying to requests and/or adding features in new releases.
I see three ways:
have your application NOT expect the folders but create them on demand.
or have the application create the folders at startup.
or you could just add dummy files in the folders :) just thinking out of the box.