How to make sure Jenkins has permission to delete files - windows

I am running jenkins on windows under a domain user with administration rights. Part of my build script delete previous artefacts. Jenkins will successfully build once, after that it fails with
You do not have sufficient access rights to perform this operation.
On the delete artefacts line which looks like this:
Remove-Item -Path $pathArtifacts -Recurse
Jenkins created these artifacts so why can't it delete them? The job config is very simple and just runs a build.bat after svn checkout. The files are local and just on the C drive

-force was the answer. Simple
Thanks Christopher

Related

Jenkins without Git Repository

I have a source code using which I want to test some processes through Jenkins.For that I've installed Jenkins and plugins as well. But I do not have internet access to my machine so I have my source code in a local folder instead of Git.
Please help me to configure Jenkins without git.
Thanks a ton in advance.
in the build steps, you can do something like
cd C:\users\user\Documents\Projects\
// build here
if you're in a different directory, you need to do:
cd D:\Projects
D:
// build here
But deleting the workspace option won't work now. since your artifacts will be stored in the current directory and the workspace is a different directory. you can add an additional step, in this case, to clean up things or you can change the workspace from the advanced option in the general tab.

How to define Background Intelligent Transfer Service (BITS) step to copy zip file from source to destination under Teamcity build step?

There is a scenario in which I have to define a build step under Teamcity deploy job configuration. Wherein a compressed file needs to copy from shared drive to udeploy. But firstly I am trying to copy to local drive(WINDOWS OS) for testing.
I am using below command to perform the operation in POWERSHELL, its working fine as expected locally.
Start-BitsTransfer -Source \Shared_Drive_Path\File_Name.zip -Destination Destination_Path
Now, I need to define this command under Teamcity Deploy Job Configuration for its execution.
What configuration i will be requiring to achieve this thing.
Anybody suggest here.
Thanks in advance....... !!

Change Jenkins job workspace

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]

How can I copy the artifacts from Teamcity to another server?

how can I copy the artifacts from Teamcity to another server?
Thanks
The way I have done this, make things a lot easier.. Setup another configuration that pulls in, via artifact dependencies, all the files you need then run a cmd script to xcopy/copy the files to another drive on the network. You can do this using cmd script, vbs, python, shell etc..
Remember, you only need to refer to directories as if they were local as you would have your script in the same working directory
i.e cmd script :: xcopy .\"my build artifact(s)" \path\to\drive\on\my\network\"my build artifacts"
It doesn't get easier than that.
Naturally, if your artifacts are huge, then you may want to consider your more complicated option. However, TeamCity currently have a ticket pending, which you can vote on, that allows you to run multiple runners in one configuration - so you could just add your cmd script to the same configuration to save the copy time; please vote if can spare a minute:
http://youtrack.jetbrains.net/issue/TW-3660
There is a Deployer plugin, that supports deploy by fileshare/SMB, FTP, SSH and other means. The usage is basically the same as the Artifact paths.
We have used just samba, so you must enter:
target Host path: //server/drive/myfolder
Username: mydomain\myusername - in our case we had to write domain
here too
Password: ****
Domain: mydomain
and in path just select the files as in artifacts:
product/* => product.zip
and it will create file //server/drive/myfolder/product.zip
You can do it from your build script or externally.
If you are looking to get artifacts copied from a remote build agent to the primary TeamCity server, you may want to look into configuring Build Artifacts under the General Settings.
According to TeamCity's wiki entry on BuildArtifacts (http://confluence.jetbrains.com/display/TCD7/Build+Artifact) "Upon build finish, TeamCity searches for artifacts in the build's checkout directory according to the specified artifact patterns. Matching files are then uploaded ("published") to the TeamCity server, where they become available for download through the web UI or can be used in other builds using artifact dependencies."

CruiseControl.Net: How Does One Clear Obsolete Build History?

I just started using CCNet, and in the process of getting my build projects set up I racked up a lot of build history from trial and error. I really don't want to keep that old stuff around, but I can't seem to see where/how to get rid of it. I'm sure this is a silly question, and I apologize if I'm overlooking something that should be obvious. I did RTM and Google for about a half hour, and poked around my CCNet installation, but it's not jumping out at me. I deleted the state files for the projects (don't know if that has anything to do with it), but the old builds are still there if I drill into a project's stats from the dashboard. Any suggestions? Thanks.
Answered: I had explicitly set the artifacts directory to a location that was not under the CCNet server directory and consequently never looked in it again... went looking and, disco, there's the build histories.
Don't forget you can use Artifact Cleanup Publisher to keep your build history from growing to the size of Mars over time.
Assuming you have a project called "Dev" and you've installed CCNet into the default location, you'll have a folder called:
c:\Program Files\CruiseControl.NET\server\Dev
and a Dev.state file in:
c:\Program Files\CruiseControl.NET\server
Just delete both the folder and the state file.
What you're looking for are the "artifacts" folders. Check your ccnet.config file for the tag
Stop your service, delete the artifact directory folder, and restart your service.
The logs are stored in the artifacts directories under artifacts\MyProjectName\Build\log*.xml.
The State file stores things like the last build date, time, info.
Best to stop the service, and then delete the .state in ProgFiles\CC.net\server and also delete the artifacts\MyProjectName\Build\log.xml files.
As mentioned above, use the Artifact Cleanup Publisher to keep the number of artifacts to a sensible level.
If you have a lot of projects and need to do a retrospective cleanup, you could use the following Powershell script to remove old log files:
$limit = (Get-Date).AddDays(-60)
get-childitem -Path D:\Builds -filter MatchMyProjects.* | %{
$projectPath=$_.FullName
$logsPath=$projectPath + "\Logs"
write-host Removing logs from folder $logsPath
Get-ChildItem -Path $logsPath -Force -Filter *.xml | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
}
Thanks to this answer: Delete files older than 15 days using PowerShell

Resources