Jenkins CI Server – Resetting a build number and cleaning a build

I’ve used a script to reset the build number during the migration to a new continuous integration server – namely Jenkins from Hudson.

The following script will remove all the workspace builds from Jenkins that exist, reset the build number for all projects specified
in the .hudson/jobs directory.

Use it with care. I take no responsibility for misuse of this or bugs etc…

On another note, there is a plugin available for Jenkins that allows you to change the build number, see: http://wiki.hudson-ci.org/display/HUDSON/Next+Build+Number+Plugin

 Bash |  copy |? 
#
# Hudson build cleaner
# Cleans out all builds for projects that exist in the directory
# Resets the build number to 1
# Backup all projects before running this
 
function cleanbuild {
 
  echo "cleaning $1"
  cd $1
  ls -l
  rm -Rf builds/*
  rm -Rf lastSuccesful
  rm -Rf lastStable/
  rm -Rf workspace/*
  rm -Rf modules/*
  rm -f lastSuccessful lastStable
  rm -f nextBuildNumber
  touch nextBuildNumber
  echo 1 >> nextBuildNumber
  cd -
}
 
for project in `find -L -maxdepth 1 -type d -name '*' ! -name '.*' -printf '%f\n' | column`
do
  cleanbuild $project
done

About the author
Currently there is no additional info about this author.
Comment on this post