Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###########################################################################
- function get_files {
- # determine the changed files and extract them from the repo to the build structure.
- git diff-tree -r ${ORIGIN}..${BRANCH} |
- while IFS= read -r line
- do
- COMMIT_ID=$(echo $line | cut -f4 -d" " )
- SOURCE=$(echo $line | cut -f6 -d" " )
- echo "Identified: " ${SOURCE} " Commit: " ${COMMIT_ID}
- TARGET=$(basename ${SOURCE})
- echo "Target : " ${TARGET}
- echo ${TARGET} >> ${BUILD_PATH}/etc/build.txt
- echo "Extracting source from repo: " $SOURCE
- git show ${COMMIT_ID} > ${BUILD_PATH}/${SOURCE}
- echo "Building targets:"
- done
- }
- function build_targets {
- FILES=$(cat ${BUILD_PATH}/etc/build.txt)
- for i in $FILES
- do
- echo "Compiling: " $i
- done
- }
- function prep_build_tree {
- #Check if build structure exists
- if [[ -d ${BUILD_PATH} ]]
- then
- # clean source from the local build structre by removing and rebuilding it
- echo "Cleaning old build structure"
- find ${BUILD_PATH} -type f -exec rm -v {} ;
- else
- # Create build structure
- echo "Creating build structure"
- mkdir -p ${BUILD_PATH}/APP/SOURCE
- mkdir -p ${BUILD_PATH}/APP/COPY
- mkdir -p ${BUILD_PATH}/etc
- mkdir -p ${BUILD_PATH}/LOADLIB
- fi
- }
- ##############################################################################
- read oldrev newrev refname
- echo "Old revision: $oldrev"
- echo "New revision: $newrev"
- echo "Reference name: $refname"
- BASE_DIR=/home/mfcobol/SDLC/BUILD/Dev-Build
- BRANCH=$(basename $refname)
- #determine build type:
- # dev branch performs build using the dev build structure checked against master
- # other branches perform local builds for that branch only checked against dev.
- case $BRANCH in
- dev ) BUILD=dev
- echo "Dev build identified: Branch: "${BRANCH}
- ORIGIN=master
- BUILD_PATH=${BASE_DIR}/${BUILD}/${BRANCH}
- prep_build_tree
- get_files
- build_targets ;;
- * ) BUILD=user
- echo "User build identified: Branch: "${BRANCH}
- ORIGIN=dev
- BUILD_PATH=${BASE_DIR}/${BUILD}/${BRANCH}
- prep_build_tree
- get_files
- build_targets ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement