SHARE
TWEET

JONATHAN NICOL / BITBUCKET Example conversion to Coldfusion

a guest Nov 18th, 2014 328 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--- ref: http://jonathannicol.com/blog/2013/11/19/automated-git-deployments-from-bitbucket/ --->
  2. <!--- Note: Mirror the Repo one time only before using fetch and checkout --->
  3. <!--- Note: git clone --mirror git@bitbucket.org:<username>/<repo-name>.git --->
  4.  
  5. <!---
  6. The MIT License (MIT)
  7. [OSI Approved License]
  8. The MIT License (MIT)
  9.  
  10. Copyright (c) 2014 Steven Benjamin
  11.  
  12. Permission is hereby granted, free of charge, to any person obtaining a copy
  13. of this software and associated documentation files (the "Software"), to deal
  14. in the Software without restriction, including without limitation the rights
  15. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16. copies of the Software, and to permit persons to whom the Software is
  17. furnished to do so, subject to the following conditions:
  18.  
  19. The above copyright notice and this permission notice shall be included in
  20. all copies or substantial portions of the Software.
  21.  
  22. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  28. THE SOFTWARE.
  29. --->
  30.  
  31.  
  32. <!--- Protect from accidential execution --->
  33. <cfparam name="url.key" default=""/>
  34. <cfif url.key NEQ "asdfgfh9gjf_hd7ss_k3rurj4fhf3dkj" OR NOT isDefined("form.payload")>
  35.     aborted.
  36.     <cfabort>
  37. </cfif>
  38.  
  39. <!--- deserialize the posted json packet --->
  40. <cfset RepoStatus = DeserializeJSON(form.payload)>
  41.    
  42.    
  43.    
  44. <!--- loop through the commits to get the branch --->
  45. <cfloop array="#variables.RepoStatus.commits#" index="commits">
  46.     <cfif variables.commits.branch NEQ "undefined">
  47.         <cfset branch = variables.commits.branch />
  48.         <cfbreak>
  49.     </cfif>
  50. </cfloop>
  51.  
  52.  
  53. <!--- Write the script --->
  54. <!--- indenting ommited to properly format text file --->
  55. <!--- IMPORTANT --->
  56.     <!--- a) Change the account the Coldfusion Service Logs on with --->
  57.     <!--- b) Log in as that account and set file permissions and SSH Keys --->
  58.     <!--- c) Register the public key with bitbucket --->
  59. <cfsavecontent variable="gitInstructions">
  60. <cfoutput>
  61. ##!/bin/sh
  62. cd E:/REPOS.GIT/#variables.RepoStatus.repository.name#.git
  63. git fetch
  64. GIT_WORK_TREE=E:/DEV/#variables.RepoStatus.repository.name# git checkout -f #variables.branch#
  65. </cfoutput>    
  66. </cfsavecontent>
  67.  
  68. <cffile  
  69.    action = "write"
  70.    file = "E:\REPOS.GIT\scripts\#variables.RepoStatus.repository.name#_dev.sh"
  71.    output = "#variables.gitInstructions#"
  72.    fixnewline = "yes">
  73.    
  74. <!--- Execute the script --->
  75. <cfexecute name="C:\WINDOWS\system32\cmd.exe"
  76.     arguments="/c E:\REPOS.GIT\Scripts\#variables.RepoStatus.repository.name#_dev.sh"
  77.     variable="execOutput" timeout=60>
  78. </cfexecute>
  79.    
  80. <!--- Diagnostics --->
  81. <!---    
  82. <cfmail to="stevenbenjaminaz@gmail.com, steven@stevenbenjamin.com"
  83.        from="server@#replaceNoCase(CGI.SERVER_NAME,'www.','')#"
  84.        subject="Git POST Hook Report"
  85.        type="HTML">
  86.        
  87.    <cfdump var="#variables.RepoStatus#"/>
  88.    <cfdump var="#CGI#">
  89.    Cfexecute Results:<br/>
  90.    #variables.execOutput#
  91. </cfmail>
  92. --->
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top