<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://blog.dangl.me/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Dangl.Blog();</title>
    <link>https://blog.dangl.me/</link>
    <description>Blogging about .Net, DevOps, Networking and BIM. Home of the free GAEB Converter.</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <item>
      <guid isPermaLink="false">1426</guid>
      <link>https://blog.dangl.me/archive/executing-nuke-build-scripts-on-linux-machines-with-correct-file-permissions/</link>
      <category>Linux</category>
      <title>Executing NUKE Build Scripts on Linux Machines with Correct File Permissions</title>
      <description>&lt;p&gt;&lt;a data-udi="umb://document/6ecb73fad5484466b0fc73c1a80f79c3" href="/archive/escalating-automation-the-nuclear-option/" title="Escalating Automation - The Nuclear Option"&gt;I've blogged before&lt;/a&gt; about the &lt;a href="http://www.nuke.build/" title="NUKE Build - Homepage"&gt;NUKE build system&lt;/a&gt;, a great tool written by Matthias Koch that allows you to define all your build steps in a C# project, complete with full IDE integration and lots of helpers to get you started quickly. Since work on NUKE has begun almost three years ago, it's grown to be a fully featured build system with a great community. We're using it in all of our projects at Dangl&lt;strong&gt;IT&lt;/strong&gt;, and the experience so far has been great!&lt;/p&gt;
&lt;p&gt;One thing, though, that's always bugged us was that when we invoked the build on Linux machines, we always had to explicitly prefix it with the shell command, like &lt;span class="Code"&gt;bash build.sh Test -Configuration Debug&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We could never directly invoke the build scripts comfortably on Linux, no matter if we were using a project that has had NUKE added over 2 years ago or for a fresh install. First, we thought it might have been related to line ending differences, since all our development happens on Windows machines. That could quickly be checked, and it wasn't the case - checkout worked as expected on Linux.&lt;/p&gt;
&lt;p&gt;After some digging to find out what we were doing wrong, it turned out that the culprit was the executable permissions of the scripts. If you're on Linux or Mac, git will recognize scripts as executable files and mark them as such. If you're on Windows, however, they're simply added as regular files. The answer from &lt;a href="https://stackoverflow.com/questions/40978921/how-to-add-chmod-permissions-to-file-in-git" title="StackOverflow - How to add chmod permissions to file in GIT?"&gt;Antwane at StackOverflow&lt;/a&gt; explains it quite nice, but in short, you just set the chmod permission via git: &lt;span class="Code"&gt;git update-index --chmod=+x build.cmd​&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Before, we saw that the file permissions were 644, or read/write:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.dangl.me/media/1193/permissions_wrong_small.png" alt="Wrong file permissions in git for executable scripts" data-udi="umb://media/840ef114ac9f47159b65596a73f9d2b7" /&gt;&lt;/p&gt;
&lt;p&gt;After updating the index, we get the correct permissions, including executable 755:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.dangl.me/media/1194/permissions_correct_small.png" alt="Build script permissions in git with executable enabled" data-udi="umb://media/6c1788f780384872b7b48697572d1ad0" /&gt;&lt;/p&gt;
&lt;p&gt;After you've done that, commit your changes. Now, your scripts should also work on Linux as expected. At least, &lt;a href="https://github.com/GeorgDangl/Dangl.SevDeskExport/runs/449039079?check_suite_focus=true" title="GitHub - Dangl.SevDeskExport - Actions Output" data-anchor="?check_suite_focus=true"&gt;it worked for us&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Happy building!&lt;/p&gt;</description>
      <pubDate>Sun, 16 Feb 2020 16:04:04 Z</pubDate>
      <a10:updated>2020-02-16T16:04:04Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1264</guid>
      <link>https://blog.dangl.me/archive/net-core-and-typescript-continuous-integration-testing-with-jenkins-on-linux/</link>
      <category>Continuous Integration</category>
      <category>Linux</category>
      <title>.Net Core and TypeScript Continuous Integration Testing with Jenkins on Linux</title>
      <description>&lt;p&gt;I've previously blogged about the &lt;a rel="noopener noreferrer" href="https://github.com/GeorgDangl/NetCoreHeroes" target="_blank" title="GitHub - GeorgDangl/NetCoreHeroes"&gt;NetCoreHeroes &lt;/a&gt;project, an Asp.Net Core demo app that features an Angular frontend. It's been my learning project for getting a nice WebDev experience in Visual Studio and Jenkins, and recently &lt;a rel="noopener noreferrer" href="/archive/unit-testing-and-code-coverage-with-jenkins-and-net-core/#comment-2870892160" target="_blank" title="Dangl Blog - Unit Testing and Code Coverage with Jenkins and .Net Core"&gt;there's been interest&lt;/a&gt; in getting it to work in Linux.&lt;/p&gt;
&lt;p&gt;Being a traditional Windows and .Net guy, I've never done a lot with Linux, but I wanted to see how easy it actually is. It actually is pretty easy and took me only two evenings of getting everything up and running on Linux. I've used a Hyper-V virtual machine with Ubuntu Server 16.04, but results should be comparable across distributions.&lt;/p&gt;
&lt;h2&gt;Install Hyper-V&lt;/h2&gt;
&lt;p&gt;On a Windows host system, you've got to install the Hyper-V role. I'm running it on an Intel NUC with an Atom processor. It sits somewhere behind the TV in the living room, is ridiculously slow, but gets the job done and costs about 300,- €.&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1124/01_install-hyperv-role-on-windows.png" alt="Windows Server 2012 R2 - Install Hyper-V Role" data-udi="umb://media/73b9e1b249d743e89029a15918cef2c0" /&gt;&lt;/p&gt;
&lt;p&gt;From the Server Manager, go to &lt;em&gt;Add Roles &amp;amp; Features&lt;/em&gt;, select the &lt;em&gt;Hyper-V&lt;/em&gt; role, confirm the GUI and PowerShell management tools and click on next until you’re in the configuration tab for &lt;em&gt;Virtual Switches&lt;/em&gt;. Since the VM will need internet access, you’ll want to select a network interface through which you’ll connect the virtual machines to the outside world.&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1125/02_select-virtual-switch-for-hyperv.png" alt="Hyper-V Virtual Switch Configuration" data-udi="umb://media/f1589b55d5084c7eaed4b854a82210fd" /&gt;&lt;/p&gt;
&lt;p&gt;In an ideal world, your virtualization host has multiple LAN ports, with a dedicated one for the virtual machines. However, the NUC behind the TV doesn't have that, so we’ll accept the risk and move on. This is mostly a problem for connectivity, since misconfiguration might make your machine unavailable.&lt;br /&gt;You don’t need to add support for Live Migrations for this example and can go with the default storage locations for VM configuration and hard disks.&lt;/p&gt;
&lt;h2&gt;Setup the Virtual Machine&lt;/h2&gt;
&lt;h3&gt;Download Ubuntu Server&lt;/h3&gt;
&lt;p&gt;Go to &lt;a href="https://www.ubuntu.com/download/server"&gt;https://www.ubuntu.com/download/server&lt;/a&gt; and download the current Long Term Support (LTS) version of Ubuntu Server. At the time of writing, that’s 16.04.2.&lt;/p&gt;
&lt;h3&gt;Provision the VM&lt;/h3&gt;
&lt;p&gt;In the Hyper-V manager, create a new virtual machine. I've assigned it 2GB of RAM and a 20GB Hard Disk, this should be plenty for a simple Jenkins instance and one Asp.Net Core demo site. Generation 2 VM have the newer features with the drawback of not being compatible with any hosts pre Windows Server 2012.&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1126/03_createvm.png" alt="Provision a Virtual Machine in Hyper-V" data-udi="umb://media/5495b803526b486fbc183edeeeab0946" /&gt;&lt;/p&gt;
&lt;h3&gt;Install Ubuntu Server &amp;amp; Jenkins&lt;/h3&gt;
&lt;p&gt;When provisioning the VM, I’ve selected to install an operating system from an image and chose the &lt;em&gt;*.iso&lt;/em&gt; that was downloaded earlier for Ubuntu Server. After the VM has been provisioned, you need to change its firmware settings to deactivate &lt;em&gt;Secure Boot&lt;/em&gt; since that’s not compatible with Ubuntu Server. After that, simply connect to it and power it on.&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1127/04_hyperv-ubuntu-installation-welcome-screen.png" alt="Ubuntu Server Installation Welcome Screen" data-udi="umb://media/1c9cd55350e54ec38a9812cdb11d98f4" /&gt;&lt;/p&gt;
&lt;p&gt;This tutorial doesn't cover how to install &amp;amp; setup Ubuntu Server itself. The setup is quite self explanatory (which I would not have expected from Linux if you had asked me a week ago).&lt;/p&gt;
&lt;p&gt;For the Jenkins installation, &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-16-04"&gt;DigitalOcean has a great tutorial&lt;/a&gt; that you should follow. However, I configured the firewall to only allow incoming traffic to Jenkins for my private home networks IP range: &lt;span class="Code"&gt;sudo ufw allow from 192.168.1.0/24 to any port 8080&lt;/span&gt;. In case your firewall is disabled in Ubuntu (&lt;span class="Code"&gt;ufw status&lt;/span&gt; returning &lt;span class="Code"&gt;inactive&lt;/span&gt;), run &lt;span class="Code"&gt;sudo ufw enable&lt;/span&gt; to activate the firewall. After the initial setup, Jenkins is running in your Linux VM:&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1128/05_jenkinswelcome.png" alt="Jenkins Welcome Screen on Ubuntu Server" data-udi="umb://media/6e2331f8288f40548c5d7bffb2efa0e4" /&gt;&lt;/p&gt;
&lt;h2&gt;Install Development Environment &amp;amp; Tools&lt;/h2&gt;
&lt;p&gt;On the build server, you’ll need dotnet and npm available.&lt;/p&gt;
&lt;p&gt;First, follow the official &lt;a href="https://www.microsoft.com/net/core#linuxubuntu"&gt;Microsoft .Net Core Linux installation instructions&lt;/a&gt; to enable dotnet support. To install npm, &lt;a href="https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions"&gt;run these commands&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;span class="Code"&gt;curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -&lt;br /&gt;&lt;/span&gt;&lt;span class="Code"&gt;sudo apt-get install -y nodejs&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;Jenkins Plugins&lt;/h2&gt;
&lt;p&gt;This one is easy. There’s already support for jUnit test results in Jenkins, meaning the TypeScript tests are already supported. For the xUnit based dotnet tests, install the &lt;a href="https://plugins.jenkins.io/xunit"&gt;xUnit plugin in Jenkins&lt;/a&gt; and you’re good to go.&lt;/p&gt;
&lt;h2&gt;Configure Jenkins&lt;/h2&gt;
&lt;p&gt;The NetCoreHeroes project has both .Net and Angular unit tests that are going to be run in Jenkins.&lt;/p&gt;
&lt;p&gt;The project's SCM git repository is located at &lt;a rel="noopener noreferrer" href="https://github.com/GeorgDangl/NetCoreHeroes/" target="_blank" title="GitHub - GeorgDangl/NetCoreHeroes"&gt;https://github.com/GeorgDangl/NetCoreHeroes/&lt;/a&gt;. You can take a look at the project to get a starting point for your own CI builds. For Linux, I've had to deviate a bit from my standard configuration. The awesome &lt;a rel="noopener noreferrer" href="https://github.com/mmanela/chutzpah" target="_blank" title="GitHub - Chutzpah"&gt;Chutzpah&lt;/a&gt; JavaScript test runner is only available for Windows, so I had to switch to &lt;a rel="noopener noreferrer" href="https://karma-runner.github.io/1.0/index.html" target="_blank" title="Karma Runner GitHub Pages"&gt;Karma&lt;/a&gt; for the Linux environment. I get that the Karma runner is actually much more used, but it doesn't integrate as seamlessly in Visual Studio. In the &lt;a rel="noopener noreferrer" data-udi="umb://document/de1e9b998b584fc6b63002a9dbb02ae5" href="/archive/netcoreheroes-angular2-with-net-core-in-visual-studio-2015-part-i/" target="_blank" title="NetCoreHeroes: Angular 2 with .Net Core in Visual Studio 2015, Part I"&gt;NetCoreHeroes posts series&lt;/a&gt;, I've described the complete way from setting up the project to a fully automated testing and deployment scenario with Windows.&lt;/p&gt;
&lt;p&gt;Back to Linux, here's the Jenkins build configuration:&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1129/06_jenkinsbuildconfiguration.png" alt="NetCoreHeroes Jenkins Build Configuration for Linux" data-udi="umb://media/2e784c9b9fc3421abf5bbee181eacaba" /&gt;&lt;/p&gt;
&lt;p&gt;And the post build actions to publish the test results:&lt;/p&gt;
&lt;p&gt;&lt;img id="__mcenew" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.dangl.me/media/1130/07_jenkinspostbuildactions.png" alt="Jenkins Post Build Actions for NetCoreHeroes with Angular and Asp.Net Core on Linux" data-udi="umb://media/c2b1e6245634435b831423c0f28fe0b0" /&gt;&lt;/p&gt;
&lt;p&gt;Save the config, click on &lt;em&gt;Build Now&lt;/em&gt; and take a look at what your unit tests have to tell you:&lt;/p&gt;
&lt;p&gt;&lt;span class="Code"&gt;HeroService.HeroService getHeroes should have expected fake heroes (from PhantomJS 2.1.1 (Linux 0.0.0))&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;.Net Core and Linux really IS easy!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Happy platform-independant testing!&lt;/span&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 29 May 2017 20:52:08 Z</pubDate>
      <a10:updated>2017-05-29T20:52:08Z</a10:updated>
    </item>
  </channel>
</rss>