Searching for files containing a specific word across all projects.
search cancel

Searching for files containing a specific word across all projects.

book

Article ID: 194444

calendar_today

Updated On:

Products

CA Harvest Software Change Manager

Issue/Introduction

We have currently 780 active repositories in the Harvest SCM database and have to search in all item versions stored for specific strings.

A search project by project with "Find version" is too much effort and time consuming. 

Do you have a procedure or query to perform a string based search in the database itself.

Environment

CA Harvest SCM version 12.x, 13.x

Resolution

One option is a field-developed utility called “HarSpy”.  Here's where you can find more information about it: https://community.broadcom.com/enterprisesoftware/communities/community-home/digestviewer/viewthread?MessageKey=5e62575a-7d03-4085-b22a-f95e87b5dadf&CommunityKey=875def62-85de-4797-9dc1-7a31010427b8&tab=digestviewer#bm5e62575a-7d03-4085-b22a-f95e87b5dadf

The HarSpy utility is offered as-is and is unsupported.

If HarSpy doesn’t accomplish what you need to do, the other option would be to set up a batch script to cycle through a list of project names and use the hsv command to search through all the projects one-by-one.  Here’s an example Windows batch script that would do it:

***************************************************************************************************************

ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

set sqlcmd="echo select environmentname from harenvironment where envisactive = 'Y' | hsql -b win2k12r2 -usr harvest -pw harvest -s -nh"

echo. > hsv.log

for /f "usebackq tokens=*" %%a in (`%sqlcmd%`) do (
  echo Project = %%a >> hsv.log
  hsv -b win2k12r2 -usr harvest -pw harvest -en "%%a" -vp "\\" -s "*.*" -wp "%~1" -ic -it nt -oa hsv.log -wts
  echo. >>hsv.log
)

***************************************************************************************************************

And here's an example of what this would look like for Linux:

***************************************************************************************************************

#!/bin/bash

echo '' > hsv.log

while read -r line
do

  if [ -n "$line" ]
  then
    echo Project = "$line" >> hsv.log
    hsv -b olnx77-scm1304 -usr harvest -pw harvest -en "$line" -vp "\\" -s "*.*" -wp "$1" -ic -it nt -oa hsv.log -wts
    echo '' >> hsv.log
  fi

done < <(echo "select environmentname from harenvironment where envobjid > 0 and envisactive = 'Y'" | hsql -b olnx77-scm1304 -usr harvest -pw harvest -s -nh)

***************************************************************************************************************