Add file my-scripts/chatgpt/findStringInRepositoryBranches.sh
This commit is contained in:
30
my-scripts/chatgpt/findStringInRepositoryBranches.sh
Executable file
30
my-scripts/chatgpt/findStringInRepositoryBranches.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Output file to store the results
|
||||
output_file="grep_results.txt"
|
||||
|
||||
# Initialize or clear the output file
|
||||
> $output_file
|
||||
|
||||
# Get the list of remote branches
|
||||
git fetch --all
|
||||
branches=$(git ls-remote --heads origin | awk -F/ '{for(i=3; i<=NF; i++) printf "%s%s", $i, (i<NF ? "/" : ORS)}')
|
||||
|
||||
# Iterate over the branches and grep for "_ID_BUILD_TYPE" in "Jenkinsfile"
|
||||
for branch in $branches; do
|
||||
git checkout "$branch"
|
||||
if [ -f "Jenkinsfile" ]; then
|
||||
if grep -q "_ID_BUILD_TYPE" "Jenkinsfile"; then
|
||||
echo "Branch: $branch - Found '_ID_BUILD_TYPE'" >> $output_file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Switch back to the original branch
|
||||
git checkout -
|
||||
|
||||
# Display the results
|
||||
cat $output_file
|
||||
|
||||
# Clean up the output file
|
||||
rm $output_file
|
||||
Reference in New Issue
Block a user