[NOW-SDK walkthrough pt. 2] Linking the ServiceNow SDK to a source control like GitHub
okay so what I wanted to do today was address something that I kind of skipped over last week I was going to attach this to Source control but I realized I didn't have a GitHub credential made on my instance yet and I didn't want to risk showing off an API key or anything like that so I just skipped over that process and said I'll do Source control another time but during that time if anybody was there we kind of had a like internal monologue uh a couple of us musing on whether we should do git GitHub or Source control directly from my local machine into a GitHub repository or should we utilize the service now version of source control that also attaches to git or GitHub because that's two different ways and almost everybody in the service now world would be used to doing it via the platform so as a reminder for anybody that might be watching this the way that you normally do Source control for your applications within the service now platform uh there's two main ways that you can do it uh for those that are a little bit more old school uh you would go to Studio well let me let this load first you go to Studio and then you would attach one of these applications to Source control you would say link to Source control and you would put in your repository URL uh select your credential uh pick the branch us let you can either let it name it for you or you can use main or whatever the defaults are and then you would link it to Source control now it be in GitHub the other way to do it would be through app engine Studio similar similarly uh you go go in here pick an app and then link it to Source control so if I load up the ones we've been working on up here is a source control button and you can link it to Source control same Fields as the other studio so that's the normal way to do it uh the more traditional coding way to do if you're traditional Dev I keep keep doing this traditional traditional Dev um you would create your repositories through your local git because you would have G installed on your computer on your local machine and you would push to you would commit to local versions of your repository and then you would push it to wherever it's stored remotely like GitHub or get bucket or anything like that um and you would work directly from that and so there's so many different implications of well do I do it that way the traditional way or do I do it through the service now way which is what everyone's used to hey whz um so we were talking about on the last stream like oh I think we should do it via the normal service now way and then I would pull that repository into my computer and work from there instead then it would be able to everybody would be able to install it through the normal ways of doing it in service now but then I kept thinking about that like and if well if I'm doing it that way where with a app linked directly from service now to GitHub then I would want to be committing the same way and pulling code the same way but I want to use the SDK and so that would create conflicts wildly back and forth and so I went I just went over to the product team and asked I I messaged Jay and I said hey Jay um do you recommend this way and I explain the normal service that way uh or do I or would I just publish my uh folder directly to a GitHub repository and work from there and push and pull from there and uh he said the lad so we're going to completely ignore service anal Source control and use Source control the more traditional way which I guess if you're using the SDK and CLI that's probably what you're used to um it's just that now I want to make sure that people that are only within the service now ecosystem make sure they know what they should be doing to get that to work so we're going to be working on that today um what I want to try to do is link this a source control and then show that I can push and pull this app to another instance uh all from my one local instance of this app uh so some of the some of these steps I'm going to um be skipp hey ay welcome um I'm going to be taking some Liberties and skipping a few steps because my machine has always been set up with a lot of this stuff uh because of like hotober Fest and stuff like that so I'm going to try to explain some of the steps that new what viewers might be missing but this is how you would link to Source control if you're working out of the SDK and then how to push and pull into new instances so um I already have a bunch of updates on this app that I've converted from service now into the SDK uh and then I want to do Source control on VSS code there's a bunch of little tabs on the side one of them is Source control uh the first one initialize repository that's if you want to initialize a place to store this app on your local machine um and potentially push it to a remote server like GitHub later but if you go into vs codes extensions and look for GitHub there is an extension called GitHub desktop and that's the one you want to install completely and then you'll be able to uh do a lot of the GitHub steps uh through VSS code and so if I I I want to push this through Source control so that anybody can utilize this and everyone can start working on it if they want to uh I press publish the instance uh published to GitHub if you've not linked your vs code yet this is where it would uh open up up a uh off basically an off a login system for you to log into GitHub to say h this is my account um I want to give access to it I have two Factor on so then it would Al also send a notification to my phone or I have to open it up and do a number two factor into it but I've already done that step so that's what you don't see so again things I've skipped over and installing GitHub desktop and linking it and the integration into vs code and then logging into my account already I've already done that um and I want to create a public repository and uh I want all of this the entire folder to be included so I'm going to say that and what did it name it well it's floing I haven't done this part yet so I actually this is me doing it live wow there's a lot of files in here so a lot of that is packages of the node js and like all the different um libraries that are included in here uh so it is building the repository I believe there it is and Publishing it and then I'm going to open up GitHub and see if that folder is there let me put this on a different screen while I wait for that and let's see if that repository has made it okay so here's my GitHub account and there it is earo instance and if I look at it it should have all of my new stuff including yep and there's my to-do list that I've been showing on my screen and everything so that's that's it's really straightforward on how to do Source control if you have these things installed on your computer um that's how fast it was for me to initialize a new repository and push it um into get along with my new stuff so that problem of me accidentally like I really messed up a um a field last time because I made a change on the platform and then didn't fetch that change in my SDK and that got over when I deployed it and then it messed up a dictionary field really badly all that would have been solved if I had just made sure that this was Source controlled first cuz I could always roll back a source control or go back to an earlier version okay so now that that is done um I'm going to show me attaching this app to a new instance and so if y'all remember so this is earo my earo instance and it's here I have it installed under this app it's called SN load faster uh my SDK app is called s np- twitch so service now Dev program twitch that's my app uh and it's installed on the earo instance and if I go to the Earl instance which I also have and log in real quick you'll see that this app doesn't exist um I try to I try to push in sndp D twitch and it didn't go through um so what I want to do is install that app into this instance because it doesn't have it yet and if I go back to VSS code I am currently in my SDK and it's doing that weird thing again uh but if I go through the SDK and look through all the commands um the things that you want to remember to do is create a new uh authentication for an instance and then you're going to deploy it so right now if I go to now SDK off list it'll show that I have one for I have two authentications both for the earo instance one as my abl tutor account and one as earo uh my admin account I mean uh .2k and so whenever I say things like like deploy or fetch it will automatically go to the default one right here so my default authentication Alias is this one uh earo and it automatically will push it to ear. service-now.com under the username of earl. that's my because it's my default Alias uh but now I want to push it to a different instance so what I'm going to do is say now SDK off save and I'm going to call this one Earl because that's my Earl instance and it's going to walk me through shouldn't walk me through uh oh interesting so it's asking if I want it to be um on my just deploying to my local computer uh because technically it's stored on my local computer right now uh but right now I'm going to want to push it to earl. service now.com and then it's going to ask me for right username so I try to default to admin but I have a earl. duk one here and then my password and then it's going to try to log in yeah okay it did so if I do uh off list again it should show three now there okay perfect so I have one Alias for my Earl instance and I have one Alias two aliases for my earlier instance and now but I notice that I still have default set to my earo instance so now if I ever want to push to anything not to my earo my default instance I have to just make sure to add this parameter uh to it and then say which Alias to use like so and so uh I'm going to make sure I I'm going to make sure I fetch from the earlier instance default just to make sure it's synced up and now I'm going to deploy to the Earl instance and I think that's all I need to say is now SDK deploy under the auth authentication of Earl so it should be pushing it we're waiting we're waiting and it looks like it did it so now if I jump back into my Earl instance and refresh up here I can go in wait for it to load of course and well and if I look for sndp twitch if I click on it then oh where'd it go what happened well it's switch to the scope am I in it oh yeah because that's just a switching of the scope right okay so if I open the application page and we're waiting and here it is exactly as I left it in fact let me go check under my module table and here's my that to-do list that I showed earlier uh now I've deployed this this one app to two instances all via the SDK and if I ever make changes to this app which we're going to do on stream right now I can push this to Source control uh and we'll be good but yeah so that's how the SDK Source control works really straightforward and to demonstrate even further I'm going to uh move this silly to-do file out of uh the source folder into a readme file with uh markdown basically uh so if I where it should be not under metad data is there a reading file on here oh no read me file okay I'll create one so readme.md because I like markdown move all that stuff here and I'm going to replace all of these silly SL slash with I think the notation is like is it this for check boxes or is it the other way around okay it's Dash and then the checkbox perfect so I'm going to replace all of that oops let me add a space to that okay now it's a checkbox should be at least and let's this is markdown so I can start making categories instead oh this isn't this should be a category okay um Samy twitch service now I fixed that one so I'll mark that as okay sorry I got carried away with updating my checklist uh we don't need this JS file anymore because it wasn't actually doing anything for JS so I'm going to to delete that and we should be good um let me deploy build and deploy this build deploy to earo so once that builds and deploys on I'm going to Source control it which I guess I should have done first doing things out of order right so that's done um you know what I'm actually interested in seeing on my earlier instance what happens to the uh that file in the module table is it still there do it get or does it get deleted oh got deleted as it should have cool yeah that to-do file is not here anymore all right cool so it it properly deletes it okay so that's working so let's go commit that to Source control so I can see the prettier markdown file uh and if this is your first time doing Source control directly without going through service now lot easier in my opinion than going through the service now integration of source control but when you update any of your files inside of your SDK and your folder on your computer you'll notice the number of changes on files will appear over the source control button so according to this eight of my files have been changed and here you can actually go through and look at what has been changed like if I click on here uh all this green means I've added a I've added these lines and because it's a new file it's all green uh similarly if I go to the to-do file it will show as deleted up here um but I can also look at other changes so it looks like some metadata files have also been changed automatically when I deployed uh so you're going to expect a lot of those things to automatically update whenever you do a deploy or a fetch but when you if everything looks good here uh what you want to always do is provide a good clear commit message of what you just did so moved my to-do moveed to-do list from sourcejs file to a root uh markdown file and I will commit that and so now I've committed those changes to my local version of this app which is is still on my computer and then the sync button will show up and it says hey uh if you press this button I'm going to take your version of the app and I'm going to push it to the remote location and that will be the new newest version sometimes you'll see a down arrow and that means hey there's changes on the remote app that you don't have yet uh you can download them now and sometimes you'll see both because you can do both if those files aren't in conflict and if there are conflicts then that's when you would choose which file is correct or merge them uh that's called merge conflicts and you would work through those but if in if you're not working on the same files as somebody else or you don't get 2D out of sync uh 2D synced then it should be a pretty simple download everything or upload everything and so right now I have upload everything I'm going to go ahead and and push those changes to the remote and say okay and all from vs code I have deployed I have updated my app I have deployed to a new instance I have uh edited Source I've attached The Source control and I have updated the source control so that other people looking at the repository can now access all of my changes and if I jump back to GitHub and go back to the base of this repository there's my new readme file with all the checkboxes because markdown interprets it properly as checkboxes if you know the notation and now anybody that goes to this github.com du/ earo instance will be able to see my to-do list and take this entire app uh sync it to your computer download it to your computer and then run the SDK to deploy it to your own instance uh there you go sometimes I think I'm going to be able to explain this stuff really quickly but 30 minutes has already passed and now I realize I am so wordy and um these videos get long and I'm thankful for anybody that is watching the video on demand afterwards that sat through all that welcome to the SD and Source control yay okay let's shift gears e e e e e e
https://www.youtube.com/watch?v=PUcDQU-rsng