What is continuous integration in C++ | easy and epic 2021

continuous integration

Today we are talking about continuous integration something that most software projects should be using now for those of you who don’t know our continuous integration or C. I. as often referred to is the process of continually integrating your car during development now this might not make much sense but what essentially is build automation and testing to cut a long story short in a software project where multiple developers across multiple different platforms are all working on that project and continually updating that card a lot of things can go wrong someone for example might not compiled a card on all platforms or in all configurations and as a result it might completely break the bill father developers or just might basically contribute bugs additionally some box might not be caught through a compilation error I mean I think it’s pretty reasonable to expect someone to first compiled a card before they actually committed especially if it’s a serious software project however a lot of bugs obviously manifest themselves at runtime in the mind of the apparent specific hardware and specific platform. continuous integration continuous integration

configuration

What is specific configuration it’s really not that feasible for developer to sit down and have to spend like an hour testing everything because they would probably rather be working on something else if you need them to be working on something else so obviously some problems can only be called during runtime by potentially using units hassle some kind of testing framework that you probably integrated into the project to make sure that everything is running correctly but it’s quite common for you to want to run that on multiple platforms multiple configurations all that stuff and that burden falls onto the developer instead of developer working on actually in our software engineering actually programming will card and fixing all the bugs they’re going to be stuck doing all of the testing now that he is not ideal and that’s what continuous integration comes in it can help us automate that entire process of making sure that the code compiles on all platforms in all configurations for everyone and then also run some basic tests or any kind of automation tests that your heart is.  continuous integration continuous integration

You’ve actually created to make sure that everything is a C++ this is definitely one of those things that you don’t think you need until you realize that you did everything just getting out of hand if we completely dumb this down to what it is at its core basically what we want to be able to do is build out card off to every commit that we make and then also or maybe brown the application to just see doesn’t run without crashing what’s the output potentially and that’s what we’re going to be doing today we’re going to be setting up a C. C++ project so that we can automatically build and then cast our application every time and you commit is pushed to get help and this is getting really bright and maybe if I just. Is this via wet going to dynamically change the set and everything’s going to be a C++ because it needs to because I need to get this but you’re done otherwise my family’s going to stone seventies Jenkins today as a continuous integration environment Jenkins is completely free and open source I’ll leave a link in description below if you guys to check it out it’s also something that we use on a number of projects at EA Sir I quite like it you can just run Jenkins on any computer really could run on the computer the use to develop of your card however it typically you’d set it up on the 7 because you would want to be running 247 and Saipan and with Leonard for this article to make all of this happened now wants Leonardo he lost well in art provides clinics Abbas that make it easy for you to harvest your side projects in the cloud if it runs on Lennox it runs on Linux arts. continuous integration continuous integration

Run

You need a host like a website or a game so all set up the C. I. machine like whether we today in this article are Leonard has you covered they have data centers all around the world which means that you can set up a server in a location that is like geographically close to which means that you’ll get that lower latency and you’ll get the fastest speeds possible best of all internet comes with 247 support that is 100 percent manage by humans that’s really important in case you need some help they have got your back I want to thank leaders of sponsoring this article making all of this possible show you guys how to set up an actual internet service so that we can get out Jenkins running on that and just how easy it is to set up Jenkins with Leonardo and the armament us not to give you guys $20 credit on annually are to count more on that later now literally basic staples plus program that I bring him I’ll take you guys through that in a minute but really the first step here is to set up something called a Jenkins file so that we can actually tell Jenkins what it is. continuous integration continuous integration

Project

We wanted to do with that project so here we have our report the tree inside a bunch and it’s just a really simple step of our project as you’ll see in a minute let me just take you through the depositary and show you what we’ve got here the first of those is pretty make 5.low file this is just a script for pre make so that we can actually construct out project files. We’ll get Jenkins to automatically do all of that stuff for us and that’s why inside the scripts directory we’ve got this Lennox builders’. H. file descriptor simply runs pretty make to generate make files for us and once we’ve got this make files we can call make to actually compile a project. We’ve also got this Lennox Rhonda S. H. filed description just runs out hello world program. Now we go back to our main repository folder you’ll see this hello well directory inside downsize souls we have this hello world on CPP file and you’ll see that like that’s it this is as simple as it gets really we just have a hello world program here. And so finally we have this Jenkins file in a repository this is this is the important file this is what tells Jenkins what on earth to do without project so the way this works is just the text files divided into stages here we have this build stage and this test stage 7 here in the build stages what Jenkins needs to do to build out project you can see here there are multiple steps here and there just really, ds what is echoing out building into themed line so we can say at MI marking a Lennox build script as executed well. continuous integration continuous integration

it’s important to note here that by this stage Jenkins has already checked out our repository so we’ve got this we’ve cloned the repository and now we’re able to obviously run the script files that we’ve got within the repository and we do that by fast marking them as executed Bahia and then just running them never got this archived artifacts pot this is what actually saves the build programmer as an artifact so that we can then later Ron this because you can see the next stage is test this is the testing stage and what happens here is we again mocked that run script this time as executable so that we can run it and then we run it and this runs out program. So that’s it that’s really all there is to it now we have a project and a Jenkins file which instructs Jenkins how to build and test out project now it’s over to Lynn art and take a look at how we can actually set up a new server and install Jenkins the first thing we’ll need to do is create some kind of 7 to run out Jenkins instance Leonard makes is really easy all we need to do is click on one click apps select Jenkins and ensures that region and Leonard plan this fest one should be fine for our needs we can give it a name and a rate possible at and that’s it we’re done Lanyard is now automatically going to allocate a server for us and install Jenkins on it so where did you go it’s that easy and that’s one of the things that I love about Leonard it’s so easy to get going because I don’t want to spend time setting up service stuff I want to spend time actually using myself up to do the things. continuous integration continuous integration

I got the 7 full to gain access to our serviced line we can eat the S. S. H. A. N. well we can just use this console built into limits website once Leonard has finished installing Jenkins for us we can simply navigate out browser to our service I. P. address and finish the check and set up process you can see that now Jenkins is in fact up and running and it’s asking us to retrieve the rate possible at from a files let’s go ahead and do that using themed line will plug in that password that we are traded and now Jenkins is unlocked and we can continue on with the set up process I was going to select install suggested plugins but if you’d like you can customize which plugins actually get installed once Jenkins is finished installing all about plugins will need to Krakow fast admin use I’ll just fill in these details here and click save and continue I’ll leave this U. R. L. here as it is and that’s it Jenkins is ready we can now start using Jenkins now on a fresh Jenkins install one of the things that you might want to do is install blue ocean blue ocean is just a kind of newer more modern looking you why for Jenkins this is completely optional you don’t really have to do this and in fact I tend to kind of switch between the 2 depending on. continuous integration continuous integration

What task I’m doing but I’m going to install blue ocean NJ what that’s like so we’ll select blue ocean aggregate here and just click install without re stock once that’s done we can just click open blue ocean and then let’s grant office pipeline a. Pipeline is going to be the actual continuous integration automation that we’ve been talking about our goal is to build and then test out project let’s hook this up automatically through get hub not to do that we’re going to have to create a get hop access tokens let’s pop over to get hub and set that up you know get help profile settings I’m going to click on developer settings and then personal access tokens I’m then going to click generate new token I don’t give it the name Jenkins example we’ll give it full repository access full control of repose tree hooks and also let it rate our user profile data and email addresses this is important for Jenkins because it requires it I’ll click generate taken and that’s it we’ve now got a token now I can copy and paste this into Jenkins without showing you what it is of course and. continuous integration continuous integration

I’ll click connects us like the organization that contains my repository and then the actual repository and that’s it you can see the Jenkins is immediately going to try and execute our pipeline by trying to clone the repository and then do whatever Jenkins file says let’s click on this run here to see what exactly Jenkins is doing and you can say that it failed let’s see what went wrong Mrs. calling Thrills card here you can see that it cannot run program get and it says no such file or directory that’s because out 7 doesn’t actually have to get installed and it needs get so that they can climb repository let’s go back to our serviced line and still get what already locked in as right yes and I need to type sooner I’ll just type in apt get install gets once that’s done and while we still got and line but let’s install everything else that will need will need to install make and then J. C++ that we can actually compile out card once a 7 finishes installing everything let’s go back to Jenkins and we’ll just click this rerun button here this is going to re run this specific run meaning it’s not cry check out a different, ND or anything it’s Leslie just going to rerun what just happened all right check out from version control succeeded and you can see everything else succeeded as well.  continuous integration continuous integration

Sorry about that you can see here that there are 2 phases to out pipeline we’ve got the bills that passed in 2 seconds and then the test the pasta in one second if we drop down this Lennox runs script you can see the output about script which says hello world program ran successfully yeah Hey I’m going back to our list of runs you can say that this has a green checkmark status everything succeeded and a project is in fact sunny let’s get out of blue ocean and see what regular Jenkins looks like somewhere inside Jenkins example let’s click on monster if we click build continuous integration now what’s going to happen is Jenkins is actually going to retrieve the latest commit it’s going to rate run that whole claim process and execute our pipeline again let’s see if that works out let’s click on this specific run to get more information about it you can see here that it’s already finished running this and we do in fact have a build artifacts that we chose to keep from out build which is the hello world program this is literally the Lennox program that we can while download and run on Lennox if I click it is just going to download it. continuous integration continuous integration

Finalize

We can also look at a console output which is just a kind of less formatted list sorted version of what we saw in blue ocean you can see that is built it and then it’s running yes hello world output if we flip back to I get hub repository you can see that in fact I lost commit was successful all checks have been passed because Jenkins automatically reflects that dollar back to get help so that’s super useful now the only issue here is that at the moment we have to manually click build now if we want to actually build the latest commit an hour plus tree but what we can actually do you set up a web hooks so that every time that we commit Jenkins will automatically run a build on that latest commit let’s click on our plaza tree settings and then web hooks and unless at a web hook now to set up this web hook with Jenkins we just need to drop in the U. R. L. of our server and then add full slash get hub – web hook will change the content type to be chase on and we can leave the sacred blank because we have no secrets make sure that pushes it selected he under the individual events and that’s it lets click add web hook. Now go back to Jenkins and will open blue ocean and we’ll just keep this view here with all about bail to open so that when we can bet something you we can see if it worked or not so going back to a Lennox computer now let’s go into the repository and change something I’ll go into that hello well source file and I’ll change it to say hello Jenkins instead of hello world once we’ve done that let’s commit this what about terminal let’s just check out get status okay cool we’ve got that changed file and send the file to change inside this repositories let’s go ahead and add it and they will commit it I’ll just send a message to be updated program once we’ve done that let’s push it to get help.  continuous integration continuous integration

Also See

Control Flow in C++ | Break continue return | 2021

Leave a Comment

Your email address will not be published. Required fields are marked *