Guest User

Untitled

a guest
Jul 27th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. REPONAME="xxx"
  4. REPOUSER="xxx"
  5. REPOPASS="xxx"
  6. REPOS="$1"
  7. REV="$2"
  8. SVNBUILDREPO="svn://localhost/$REPONAME/build"
  9. PHINGBUILDPATH="/var/phing/builds/$REPONAME.build"
  10. LOG="/tmp/hook.log"
  11.  
  12. modified=$(svnlook dirs-changed "$REPOS" --revision "$REV")
  13. dotrunk=$(echo "$modified"|grep -E '^trunk/')
  14. dotesting=$(echo "$modified"|grep -E '^branches/testing')
  15. dostagingsherborne=$(echo "$modified"|grep -E '^branches/staging.sherborne')
  16. dostagingqatar=$(echo "$modified"|grep -E '^branches/staging.qatar')
  17. dolive=$(echo "$modified"|grep -E '^branches/live')
  18. build=$(echo "$modified"|grep -E '^build/')
  19. echo "====================================" >> $LOG 2>&1
  20. echo "Commited branches: " >> $LOG 2>&1
  21. echo "====================================" >> $LOG 2>&1
  22. if [ -n "$dotrunk" ]
  23. then
  24. echo "TRUNK" >> $LOG 2>&1
  25. fi
  26. if [ -n "$dotesting" ]
  27. then
  28. echo "TESTING" >> $LOG 2>&1
  29. fi
  30. if [ -n "$dostagingsherborne" ]
  31. then
  32. echo "staging sherborne" >> $LOG 2>&1
  33. fi
  34. if [ -n "$dostagingqatar" ]
  35. then
  36. echo "staging qatar" >> $LOG 2>&1
  37. fi
  38. if [ -n "$dolive" ]
  39. then
  40. echo "LIVE" >> $LOG 2>&1
  41. fi
  42. if [ -n "$build" ]
  43. then
  44. echo "BUILD" >> $LOG 2>&1
  45. echo "Exporting build" >> $LOG 2>&1
  46. if [ -d "$PHINGBUILDPATH" ]
  47. then
  48. rm -rf "$PHINGBUILDPATH" >> $LOG 2>&1
  49. fi
  50. svn export "$SVNBUILDREPO" "$PHINGBUILDPATH" >> $LOG 2>&1
  51. fi
  52. echo "====================================" >> $LOG 2>&1
  53. echo "PROCESSING BUILDS" >> $LOG 2>&1
  54. echo "====================================" >> $LOG 2>&1
  55. PD=$PWD;
  56.  
  57. if [ ! -d $PHINGBUILDPATH ]
  58. then
  59. svn export "$SVNBUILDREPO" "$PHINGBUILDPATH" --username "$REPOUSER" --password "$REPOPASS" >> $LOG 2>&1
  60. fi
  61. if [ ! -d $PHINGBUILDPATH ]
  62. then
  63. echo "ERROR COULD NOT CREATE BUILD" >> $LOG 2>&1
  64. exit 1
  65. fi
  66. cd "$PHINGBUILDPATH" || exit 1
  67.  
  68. targets=$(phing -l|grep -E '^ (staging|testing|live|trunk)')
  69. trunkbuildavailable=$(echo $targets|grep trunk)
  70. sherbornestagingbuildavailable=$(echo $targets|grep staging.sherborne)
  71. qatarstagingbuildavailable=$(echo $targets|grep staging.qatar)
  72. testingbuildavailable=$(echo $targets|grep testing)
  73. livebuildavailable=$(echo "$targets"|grep live)
  74. if [ -n "$trunkbuildavailable" ] && [ -n "$dotrunk" ]
  75. then
  76. echo "Building TRUNK"
  77. phing testing >> $LOG 2>&1
  78. fi
  79. if [ -n "$testingbuildavailable" ] && [ -n "$dotesting" ]
  80. then
  81. echo "Building TESTING"
  82. phing testing >> $LOG 2>&1
  83. fi
  84. if [ -n "$sherbornestagingbuildavailable" ] && [ -n "$dostagingsherborne" ]
  85. then
  86. echo "Building STAGING.SHERBORNE"
  87. phing staging.sherborne >> $LOG 2>&1
  88. fi
  89. if [ -n "$qatarstagingbuildavailable" ] && [ -n "$dostagingqatar" ]
  90. then
  91. echo "Building STAGING.QATAR"
  92. phing staging.qatar >> $LOG 2>&1
  93. fi
  94. if [ -n "$livebuildavailable" ] && [ -n "$dolive" ]
  95. then
  96. echo "Building LIVE"
  97. phing live >> $LOG 2>&1
  98. fi
  99. cd $PD
Add Comment
Please, Sign In to add comment