Description – this is the text that appears beneath the checkbox.I set it to something like “This is a production deployment”. Label – this is the text that appears to the left of the checkbox.You will be presented with a form with the following fields: Press the “Edit…” button to create a new variable specification. Name it env.Confirm (make sure if matches the name in the script above) and set the default value to false. Step 2Īdd an environment variable to your build parameters. Now would also be a good time to make sure any subsequent steps in your build configuration are set to execute “Only if all previous steps were successful”. The rest of the fields in this build step can be left with their default values. If it is true, don’t do anything, and the build will continue as usual. If it’s false (unchecked), throw an exception that will kill the rest of the build process. The script basically checks the value of the build parameter %env.Confirm% that is set by the checkbox in the build prompt. Set the Script option to Source code and enter the following into the Script source box: Give the build step a name like “Deployment Confirmation”. In this example I’ll make it of type Powershell – you can use other script based build types (Gradle, command line, etc.), the script will simply verify if the user has checked the confirm checkbox before the build runs. Step 1Īdd a new build step to your build configuration – it should be the very first step that is run. Effectively turning a one-click deployment into a three-click deployment, with the added benefit of no added training or documentation to other users of your build server. If you check it – the build will run as it normally would. The prompt includes a checkbox asking you to confirm that you really want to run the build. At the end, upon pressing the “Run” button you will be presented with a prompt that looks something like this: In this post I will show you how to reduce the risk of accidently running a production deployment in TeamCity by introducing a simple safety switch into the build process. It’s an unfortunate consequence of making things too easy – one little misclick can become a big mistake. But, if you have a particularly busy project list in TeamCity, you will find yourself constantly double checking which “Run” button you are pressing, for fear of accidently running a deployment into production. One-click deployments are exactly that – one click of the “Run” button, and the magic happens.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |