Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!/bin/bash
  2. ###########################################################################
  3.  
  4. function get_files {
  5. # determine the changed files and extract them from the repo to the build structure.
  6. git diff-tree -r ${ORIGIN}..${BRANCH} |
  7. while IFS= read -r line
  8. do
  9. COMMIT_ID=$(echo $line | cut -f4 -d" " )
  10. SOURCE=$(echo $line | cut -f6 -d" " )
  11. echo "Identified: " ${SOURCE} " Commit: " ${COMMIT_ID}
  12. TARGET=$(basename ${SOURCE})
  13. echo "Target : " ${TARGET}
  14. echo ${TARGET} >> ${BUILD_PATH}/etc/build.txt
  15.  
  16. echo "Extracting source from repo: " $SOURCE
  17. git show ${COMMIT_ID} > ${BUILD_PATH}/${SOURCE}
  18. echo "Building targets:"
  19. done
  20. }
  21.  
  22. function build_targets {
  23. FILES=$(cat ${BUILD_PATH}/etc/build.txt)
  24. for i in $FILES
  25. do
  26. echo "Compiling: " $i
  27. done
  28. }
  29.  
  30. function prep_build_tree {
  31. #Check if build structure exists
  32. if [[ -d ${BUILD_PATH} ]]
  33. then
  34. # clean source from the local build structre by removing and rebuilding it
  35. echo "Cleaning old build structure"
  36. find ${BUILD_PATH} -type f -exec rm -v {} ;
  37. else
  38. # Create build structure
  39. echo "Creating build structure"
  40. mkdir -p ${BUILD_PATH}/APP/SOURCE
  41. mkdir -p ${BUILD_PATH}/APP/COPY
  42. mkdir -p ${BUILD_PATH}/etc
  43. mkdir -p ${BUILD_PATH}/LOADLIB
  44. fi
  45. }
  46.  
  47. ##############################################################################
  48.  
  49. read oldrev newrev refname
  50. echo "Old revision: $oldrev"
  51. echo "New revision: $newrev"
  52. echo "Reference name: $refname"
  53.  
  54. BASE_DIR=/home/mfcobol/SDLC/BUILD/Dev-Build
  55. BRANCH=$(basename $refname)
  56.  
  57. #determine build type:
  58. # dev branch performs build using the dev build structure checked against master
  59. # other branches perform local builds for that branch only checked against dev.
  60. case $BRANCH in
  61.  
  62. dev ) BUILD=dev
  63. echo "Dev build identified: Branch: "${BRANCH}
  64. ORIGIN=master
  65. BUILD_PATH=${BASE_DIR}/${BUILD}/${BRANCH}
  66. prep_build_tree
  67. get_files
  68. build_targets ;;
  69.  
  70.  
  71. * ) BUILD=user
  72. echo "User build identified: Branch: "${BRANCH}
  73. ORIGIN=dev
  74. BUILD_PATH=${BASE_DIR}/${BUILD}/${BRANCH}
  75. prep_build_tree
  76. get_files
  77. build_targets ;;
  78. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement