[ 
https://issues.jenkins-ci.org/browse/JENKINS-11716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=158929#comment-158929
 ] 

Steve Roth commented on JENKINS-11716:
--------------------------------------

One shell script workaround for renaming a job (presumes a path like 
${ITEM_FULLNAME}/builds is listed below.   Save as 'renamejob.sh'
Note this requires you to restart Jenkins after running the shell script:

Usage: renameJob.sh oldJobName newJobName pathToBuildArtifactDir

#!/bin/sh -eu

OLDJOB=$1
NEWJOB=$2
JOBROOT=$3

if [ ! -d $JOBROOT ]; then
   echo "ERROR: directory at JOBROOT=$JOBROOT does not exist"
   exit 1
fi

if [ ! -d $JOBROOT/$NEWJOB ]; then
   echo "ERROR: newjob directory at $JOBROOT/$NEWJOB does not exist"
   exit 1
fi

if [ ! -d $JOBROOT/$OLDJOB ]; then
   echo "ERROR: oldjob directory at $JOBROOT/$OLDJOB does not exist"
   exit 1
fi

echo "RENAMING JOB from $OLDJOB ==> $NEWJOB"

set +e
rm -f $JOBROOT/last*
rm -rf $JOBROOT/$NEWJOB/builds/*
mv $JOBROOT/$OLDJOB/* $JOBROOT/$NEWJOB
set -e

echo "UPDATING RUNS..."
for RUNDIR in `ls -d $JOBROOT/$NEWJOB/builds/*-*-*`; do
  echo "... UPDATING RUN AT $RUNDIR"
  if [ -f $JOBROOT/$RUNDIR/junitResult.xml ]; then
    sed -i "s/$OLDJOB/$NEWJOB/g" $JOBROOT/$RUNDIR/junitResult.xml
  fi
  if [ -f $JOBROOT/$RUNDIR/build.xml ]; then
    sed -i "s/$OLDJOB/$NEWJOB/g" $JOBROOT/$RUNDIR/build.xml
  fi
done

                
> Renaming a job does not rename the build record root dir, for a Jenkins 
> instance configured with this feature
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: JENKINS-11716
>                 URL: https://issues.jenkins-ci.org/browse/JENKINS-11716
>             Project: Jenkins
>          Issue Type: Bug
>          Components: core
>    Affects Versions: current
>            Reporter: Steve Roth
>
> We have a Jenkins instance (1.438) using the 'Build Record Root Directory' 
> feature, so we can specify an alternate directory for storing build artifacts 
> outside of the JENKINS HOME directory.
> This generally works fine.  However, I noticed that when I rename a job, I 
> lose the previous build records.
> I see a new build record directory is created, beneath the specified 'Build 
> Record Root Directory'.  However, the old build directory also exists, 
> containing the previous records.  They are not moved over to the new 
> directory.
> In other words, when the 'Build Record Root Directory' feature is enabled, 
> renaming a project causes the project's build records to be lost.
> Current workaround is to move the build record files over and use sed to 
> replace the project name in them, then restart Jenkins.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to