Tag: syndicated

  • Local Database CI Builds with Jenkins in a Container

    In two previous posts (Jenkins in a container, Adding SCA to Jenkins), I’ve showed how to configure Jenkins in a container as well as how to add the SQL Change Automation plugin. This post looks at an initial database build in Jenkins. I will build from my local repo, which gives me a bit of a pre-push check on my code.

    Note: I already have a SQL Source Control (SOC) project committed to Github that contains the database I want to build. If you haven’t done that, see this post on a basic SOC->GitHub link.

    Creating a Jenkins Job

    Jenkins calls these build processes jobs, and you see that if you set up Jenkins in a container. By default, there are no jobs, and Jenkins lets you know this.

    2019-07-27 17_23_07-Dashboard [Jenkins]

    When I click this, I get a choice of different projects. You can read about these in the Jenkins documentation, but I am just going to use a Freestyle Project. Give it a name and click the type and then OK.

    2019-07-27 17_24_04-New Item [Jenkins]

    At this point, we need to configure the job. I do like to provide a description, and normally I would set this as a Github project, but in this case, this is really just a local build..

    2019-07-27 17_30_56-SimpleTalkDB Demo Build Config [Jenkins]

    I do want to restrict which agent will run this, since I have a master agent in the Jenkins container. That one can’t see my SQL Server (and doesn’t have tools), so I’ll restrict this to the local agent on my machine.

    2019-07-27 17_31_04-SimpleTalkDB Demo Build Config [Jenkins]

    There are tabs at the top for quick navigation, but this config is really just one long page. You can scroll down as needed. Below the agents, I find the VCS section. I’ll choose git, and then enter the path the agent will need.

    2019-07-27 17_35_56-SimpleTalkDB Demo Build Config [Jenkins]

    When I scroll down to the Build area, I need to add a step. CI is just a step engine to assemble your software, and in this case, I see my Redgate SQL Change Automation plugin.

    2019-07-27 17_36_15-SimpleTalkDB Demo Build Config [Jenkins]

    When I click this, it is added as the first step. There is an implicit “git clone” checkout of code. I need to configure this step with just a few items. First, build in the local folder, rather than some specific area. We’ve already specified an agent location when we configured the Jenkins agent.

    Also, you need a package ID, which will be the place where the current state of all objects is stored. Unlike application code, the artifact is really the current version of the objects in source control, not any .exe or .dll.

    2019-07-27 17_36_38-SimpleTalkDB Demo Build Config [Jenkins]

    The only way to build a database project in SQL Server is with an actual SQL Server. In this case, I don’t have any code that would error on LocalDB, so I’ll just use that. I coudl specify my local SQL Server development database if I had the need.

    This is a test build, so I also don’t need any SQL Compare options or other switches.

    2019-07-27 17_36_47-SimpleTalkDB Demo Build Config [Jenkins]That’s it. I click Save, and I get to the main project page. Now, the test. I’ll click Build Now.

    2019-07-27 19_05_12-SimpleTalkDB Demo Build [Jenkins]

    This kicks off a build on my agent. If your agent isn’t connected to the container, you’ll need to do that now. At the bottom left of the page, I see my build working.

    2019-07-27 19_05_28-SimpleTalkDB Demo Build [Jenkins]

    The build number is a link, so click that to go to the details of the build. When you get there, you can see the build working by clicking the Console output. As you see, the output is on the right side of the screen.  As you can see, my local path worked fine, without any error.

    I also got to this part of the process on a plane, with no Internet. While there were some warnings as the plugin and other parts of the process tried to contact the PowerShell Gallery, things worked.

    2019-07-27 19_06_03-SimpleTalkDB Demo Build #1 Console [Jenkins]

    At the end, I see success, which means that the code I wrote in my database, and that was committed to my VCS, is valid. It’s a low bar, but you might be surprised how often someone breaks code by making a strange change to their project.

    2019-07-27 19_06_17-SimpleTalkDB Demo Build #1 Console [Jenkins]

    This is a basic build process, to which I can add other steps. Testing and releasing are further steps, and Jenkins can support you in these.

    Now I can move forward with additional development, knowing I have my own build system in my own environment, using Jenkins in a container.

    This Series

  • VSCode Tips–Remove the Highlighted Line

    VSCode was making me crazy as I was writing a script. I like a light theme, and every time I went to type, I saw this:

    2019-08-13 11_17_00-CreateMaskedImage.ps1 - SitC 2018 - CreateProtectManageDB - Visual Studio Code

    The highlight was distracting for me. I could see why people might like it, but I don’t. I tried the command palatte, but couldn’t find a setting that was helpful. After scrolling back and forth a few times, I decided to search.

    This SO post was helpful, and here are the steps I followed to change the setting.

    First, I opened up the Default settings from the command palette, like this:

    2019-08-13 11_21_36-CreateMaskedImage.ps1 - SitC 2018 - CreateProtectManageDB - Visual Studio Code

    Next, I searched for the “editor.renderLineHighLight” setting. I copied this line into the clipboard.

    2019-08-13 11_22_36-defaultSettings.json - SitC 2018 - CreateProtectManageDB - Visual Studio Code

    Now, go back and open the User Settings.

    2019-08-13 11_23_13-CreateMaskedImage.ps1 - SitC 2018 - CreateProtectManageDB - Visual Studio Code

    Paste in the line and change “line” in the value to “none”.

    2019-08-13 11_23_48-● settings.json - SitC 2018 - CreateProtectManageDB - Visual Studio Code

    Save this, and annoyance removed.

    2019-08-13 11_24_25-CreateMaskedImage.ps1 - SitC 2018 - CreateProtectManageDB - Visual Studio Code

  • Adding SQL Change Automation to Jenkins for Database CI

    In a previous post, I explained how to get Jenkins running in a container for your local CI work. In this one, I’ll expand on the process for database CI with a quick look at getting the SQL Change Automation plugin added to Jenkins

    The first step here is to click the Manage Jenkins menu item from the home page.

    2019-07-27 17_14_17-Manage Jenkins [Jenkins]

    This gives you a number of items on the right. Scroll down and you’ll find the Manage Plugins option.

    2019-07-26 15_41_18-Manage Jenkins [Jenkins]

    Once you click this, you see a list of the installed plugins with updates in the right. You also see a few tabs for managing and adding plugins. Click over to the Available tab for plugins that you can add, but don’t have installed.

    2019-07-26 15_41_29-Update Center [Jenkins]

    In the upper right is a Search box. I entered “redg” and you quickly see the list shrink to the one you want: the Redgate SQL Change Automation plugin.

    2019-07-26 15_41_35-Update Center [Jenkins]

    Check the box next to the plugin (in the Install column) and then click “Install without restart”. I restart isn’t needed in this case to get the plugin to work. Once you click this, you will see the plugin status appear.

    2019-07-26 15_41_46-Update Center [Jenkins]

    It should install quickly and let you know it’s done. I did this 4 or 5 times and every time it just worked.

    2019-07-26 15_43_32-Update Center [Jenkins]

    At this point, you can add this plugin to your builds. When you have a project, this will be one of the possible options. In a future post, I’ll look at actually performing a build with the SQL Change Automation Plugin.

    There are other posts in this series:

  • A Memory-Optimized Roundup – T-SQL Tuesday #117

    The summary from my fourth T-SQL Tuesday hosting for #117. This time I was scrambling a bit, but since I’ve worked with a few customers in the last year that use MOT tables, I thought this might be a good topic.

    Either everyone is on vacation or not many people think about them. Or maybe they aren’t interesting. In any case, here’s the roundup.

    Rob Farley has a win with user defined table types that are used in MOT objects. Never knew this was a possibility. Extra points for mentioning source control and DevOps.

    Kevin Chant notes he studied them for his MCSE, but hasn’t really found them useful. Mostly because of older versions and restrictions on the feature. Kevin likens this to filtered indexes, which are a nice feature, but rarely used.

    Jess Pomfret writes about some of the limitations for a feature she hasn’t used. A good summary of what they are, but don’t let her turn you off of the feature. It has its place.

    Ken Fisher has a few notes about why he hasn’t used them. Not enough memory in his systems, older versions, and he doesn’t write the code. Apparently I’ve given him some things to think about and play with, and I’m sure I’ll see more blogs from him soon.

    Johan Ludvig Brattås explains how he improved performance with a MOT table.