Use Case – Continuous Delivery for the Cloud Native Java Developer

Abstract:

Josh Long / Pivotal & Baruch Sadogursky /JFrog, May 2016: Organizations struggling to move quicker. They’re moving to smaller batches of work, microservices, that they can push through the software factory quicker.
Microservices support agility if, and only if, everything downstream of the development cycle is a well-oiled, automated machine. In this talk, join JFrog Developer Advocate Baruch Sadogursky and Spring Developer Advocate Josh Long as we look at how to quickly write a microservice and push it through a continuous delivery pipeline powered by Artifactory and CloudFoundry.

Talk Transcription:

[Josh] So what we’re going to do, I think at first, the whole point of this discussion, the whole point of, you know, Baruch and I are all very, very much interested in agility and helping developers get results quickly and so what we’re going to do is we’re going to build a very, very simple application today. Something very, very simple. And I usually focus on just the application development so we’ll start with that. But as we’ll see soon enough that isn’t nearly enough. So the goal here is to move to a place where we have the ability to go quickly, right, and we’re going to start with code. Code is very important, so we’ll go to my second favorite place on the internet.

[Baruch] So what Josh is going to do now is the same talk that he does a lot about Spring Boot and microservices.

[Josh] Just 10 minutes.

[Baruch] Instead of 45 minutes, he’s going to do it in 10 seconds.

[Josh] It’ll be fine.

[Baruch] In 10 minutes because you’re so sharp and also because I brought him here to actually say one thing. What you’re doing in this talk is awesome but it’s not enough.

[Josh] Not enough.

[Baruch] So first — and that’s the first time I can actually tell it to you to microphone and not shouting from the crowd.

[Josh] Yes.

[Baruch] So let’s do that. Do your thing and then we’ll — we’ll take it further.

[Josh] We’ll begin out journey to production with start dot spring dot io.

[Josh] This is my second favorite place on the internet. If you aren’t already in production, you should definitely be in production. I love production. You should love production. Production’s great. Production’s great this time of year. The weather’s nice. If you haven’t gone, you should go, bring the kids, bring the family. Production is better than Disney Land.

[Josh] So we’re going to start our journey here at start dot spring dot io. If you want for inspiration in the early mornings before your cup of tea or coffee, start dot spring dot io. If your children are restless and can’t sleep, start dot spring dot io. And if you suffer from indigestion and seek relief, start dot spring dot io.

[Josh] What we’re going to do is going to build a very, very simple service. We’re going to call it cdlive and we’re going to take advantage of some technologies that support building applications quickly. We’re going to use Spring’s web support here. And of course we could elect, if we want, to go down here to switch to the full version and where upon we’ll be given a list of checkboxes. Different things that we could use to support different technologies and use cases. We don’t want to choose anything else beyond the web technology. We also have a choice of language, and again, any language with objects and annotations on the JVM will work just fine. So Scala, Java, Groovy, Kotlin, et cetera. And then here, finally, we have what I call non choices. These are choices in the same way that stripping naked and running in traffic is a choice. You could make those choices but — but don’t. Please don’t.

[Josh] So here, for example, we have the version of the JVM we’d like to use. In two thousand and sixteen, anything else besides one dot eight isn’t a great choice. And here is a question, a choice that people struggle with, very often, very frequently, I’m going to do my level-headed best to explain when and where to choose which option, right here, right now.

[Josh] If by some freak fluke of physics, you find yourself stuck in the very, very distant past, far beyond modern help, then choose dot war. But if you’re here, with me, in two thousand and sixteen, then choose dot jar. This is a big part of my overarching personal guiding philosophy of make jar not war. You have choices. You have options. You should do what works for you.

[Baruch] Well, first, no results.

[Josh] No results? What do you mean no results?

[Baruch] It was saying no results. I don’t know.

[Josh] Okay.

[Baruch] But second, who will actually want to choose war.

[Josh] The people from the distant past.

[Baruch] What, like, cruel and — and war seeking bastards will choose war?

[Josh] No idea. So we’re going to go ahead and open this up. We’ve got a little zip — a little project here. All I’m going to do is I’m going to open a token strawman REST API here. If IDE wants to play. Come on out. It doesn’t really matter what you use here. I just want to have something at which we can iterate. Or on which we could iterate.

[Josh] So open this up. Come on. Come on. Cdlive application. Rest controller. Okay.

[Josh] And we’re going to build a simple endpoint here. Public string hi. Path variable string. Actually we don’t even need that. Let’s just do an endpoint here. And all I’m going to do is expose an endpoint that responds to the HTTP verb called GET and responds at forward slash hi. And there we go.

[Josh] And naturally this has got to be tested. So I’ll write a simple unit test here. I’ll say private web application context. WAC. Or even better, just WAC. I’ll tell Spring to provide that object as a collaborating object like so. And then I’ll create a mockMvc object which I can use to interact with my REST API without actually having to stand up the whole service. So I’ll say public void before. And I’ll say this dot mockMvc equals mockMvcBuilder dot with web application context bot build. And then I will preface it with at before. And we’ll create a simple test just to prove that when I evoke that endpoint, I’ll get a result.

[Josh] So this dot mockMvc dot perform. MockMvc request builders dot get hi. And expect mockMvc result matchers dot content dot — or rather status is ok and expect new result matcher. Basically saying get content. Get response as string. Okay. Dot equals hi. Okay.

[Josh] That’ll be our simple test so that we have something we — as a baseline when we change it and we can see what happens. So assert equals. We don’t need this here. Okay. Now that is a simple test. And if we run this, we should see that we could fix that. Make it a little cleaner. Almost like Groovy but not quite.

[Baruch] I just want to say, if you need a reason to write in Groovy, just look at this code.

[Josh] Yeah. Well, thanks. So.

[Baruch] It’s not because of you. It’s because of Java.

[Josh] Okay. Does it pass? It is good? It ran, but that’s not what I wanted. Run the test please. Test hi. Okay so it passed, and we can prove the negative — we can prove the positive by changing it to a negative so make it like this. Run that again.

[Baruch] That’s a mutational testing. It was.

[Josh] That failed, of course, it’s the wrong endpoint. We’ve — like this as well.

[Baruch] Incredible.

[Josh] Okay. So we got now, very, very simple application. Very simple test. We know that it’s working as we need to. Now what do I need to do now? […]

[Baruch] Yeah. You want to commit it to Git?

[Josh] I think it’s a good idea. That’s a good idea.

[Baruch] GitHub? Will it be?

[Josh] Beginning of — beginning of our journey. So what did I do? I broke it irrevocably.

[Baruch] Yeah. That’s all. You just broke it.

[Josh] What did I go?

[Baruch] Let’s go home.

[Josh] Hold on. Assert.

[Audience]

[Baruch] Yeah. You ran the test. Just rerun it. Yup. Run the test.

[Josh] Oh. Thank you. You must be this smart to ride the ride.

[Baruch] Yeah. That’s […]. He’s smart.

[Josh] Okay. Very good. Thank you. So now I’ve got code. I’m going to put it up here. Somewhere on GitHub.

[Josh] So again, today we’re going to look at Bintray, Artifactory, GitHub, Travis, uh —

[Baruch] Spring.

[Josh] Cloud Foundry and start dot spring dot io. All of them which are hosted on the web. All which are live. So, hopefully this talk will be fine but there’s a lot of — lot of variables here. So new repository –

[Baruch] It will be fine. Just good.

[Josh] It’s going to be fine. Could be worse.

[Baruch] It will be perfect.

[Josh] New. We’re going to say, cdlive. Okay. Okay. We’ll do it live.

[Baruch] We’ll do it live. A license. We need stuff.

[Josh] Something like that. There we go.

[Baruch] Yeah.

[Josh] Okay. Why are we not happy?

[Josh] Did I do something?

[Baruch] You didn’t make change, did you? Yeah. Now you made a change.

[Josh] That was helpful. Thank you. So we’ll copy this URL here. Go to the command line. Cd desktop. Git clone. Come on. Faster.

[Baruch] It’s a heavy project.

[Josh] Yeah. Clearly. Cat dot git config. PB. Actually just copy it in here. So where’s out code? Downloads. Cdlive. Git init. Copied from the desktop. Cdlive dot git config to the downloads directory. Cdlive dot git config. Git. And we’re inside of the downloads directory. So Git status. Git add. Maven w. Git add source. Git add Pom dot xml. Git status. Do I need anything else?

[Baruch] No. But Maven? You want us to be, like, you like this talk to be as painful as possible. Right?

[Josh] Yep. Absolutely. So Maven. Maven. Because I make poor life decisions.

[Baruch] You don’t run naked on streets. You choose Java 8. You’re not that bad.

[Josh] So that should be enough. Right? I’m going to have to git pull. Because I have a readme in there. Okay. Great. Git push. And there we go. We’re done, right? Surely.

[Baruch] Well. Good job. Yeah, good job. But now — now what do you, what do you do with this?

[Josh] Go home. Drink wine.

[Baruch] And then what. Don’t you want, like, to maybe run some continuous integration to check that you don’t break it occasionally?

[Josh] I don’t make mistakes. Baruch.

[Baruch] You’ve just spoke about the number of bugs that you went into your code. Don’t you want to —

[Josh] All right. Yeah okay. So maybe you’re right. Maybe some feedback will be good.

[Baruch] Okay. So let’s — and today it’s very easy. Just drop the Travis yaml file into it and you’re done.

[Josh] What is Travis?

[Baruch] Travis is a cloud — it’s a CI server on the cloud. It just takes your GitHub repository. Watches and when you add box to it, it runs the build and it fails and this is how you know how many bugs you’ve made today.

[Josh] So it’s continuous feedback. Is that?

[Baruch] It’s continuous backtracking. Like back counting. You’re back counting.

[Josh] But, I don’t make mistakes. Well no it’s — so it’s — it’s lost its ability to do Git. What the hell?

[Baruch] The first one wasn’t Git?

[Josh] Enable ver — Git.

[Baruch] No. Okay. No Git for you. That’s —

[Josh] Whatever —

[Baruch] Let’s do some version instead.

[Josh] Git status. Git add dot Travis yaml. Git commit. YOLO. Okay.

[Baruch] That’s a good message.

[Josh] Git push. Okay.

[Baruch] Messages are important.

[Josh] So now we’ve got a continuous — we got Travis in there. What else do I need?

[Baruch] And now you need to turn it on.

[Josh] Travis CI. Travis CI dot org.

[Baruch] Dot org.

[Josh] Okay. We’ll go here.

[Baruch] Sign in with. So you know Travis. You have tons of repositories here.

[Josh] A few yeah.

[Baruch] Yeah.

[Josh] So where’s our — where did we add it? Cdlive?

[Baruch] Cdlive.

[Josh] It’s already on. So turn off in case. Okay.

[Baruch] Okay. Now let’s see if it has any new builds in it.

[Josh] Home.

[Baruch] Should have a new build, right? I guess.

[Josh] We didn’t change anything, did we?

[Baruch] No, we didn’t.

[Josh] Spinnaker.

[Baruch] Spinnaker? You build Spinnaker in your free time? You — you a criminal?

[Josh] Okay. There we go. Update and that’s the old one. So we need to now —

[Baruch] Yeah. […].

[Josh] — make sure it’s updated.

[Baruch] Yeah. Let’s have an image of we’ll do it live.

[Josh] A what?

[Baruch] An animated gif of we’ll do it live. […].

[Josh] Okay. TBD.

[Baruch] Okay.

[Josh] O’Reilly

[Baruch] That’s the way to add an image. Just add the TBD of an image.

[Josh] Okay.

[Baruch] Nice.

[Josh] What I don’t understand is why Git isn’t working on that anymore? Literally — the Git plugin was working outside in the hallway. But seeing as how we’re now live.

[Baruch] No. We didn’t have subversion and ClearCase and other cool stuff. But.

[Josh] Adding —

[Baruch] You’re in Maven, you can’t complain.

[Josh] Yeah I know.

[Baruch] Subversion should be your, like, baseline.

[Josh] Git push. So now. Come on.

[Baruch] Cdlive. Cdlive. Cdlive. No. No cdlive.

[Josh] This one is somehow tied to the old one.

[Baruch] Yeah. I guess we should create a new repo. How about that?

[Josh] Fair enough. Or we could just rename it?

[Baruch] No. I think you just need to create a new repo.

[Josh] Oh here.

[Baruch] Clone. Copy. Yeah

[Josh] Again.

[Baruch] Okay. Cdlive again.

[Josh] It’s probably fine. So now go back to this. Go here, add a repository.

[Baruch] […]

[Josh] Cdlive again. This time before Gusto.

[Baruch] Refresh.

[Josh] Resync.

[Baruch] Yeah.

[Josh] Resync.

[Baruch] We’ll get there.

[Josh] How much time do we have? […]

[Baruch] We just started. I don’t know. It was like five minutes. Tops.

[Josh] When did — no, seriously — when did we start?

[Baruch] 35.

[Josh] Okay. We got time. White steps. So cdlive again.

[Baruch] Again. Here we go.

[Josh] Mazel tov.

[Baruch] All right. Now we need — now an image. Or remove the TBD. Now remove the TBD.

[Josh] Okay. For extra validation on Reddit.

[Baruch] Yeah that’s important.

[Josh] Okay. Git push.

[Baruch] Your messages are not getting any creative.

[Josh] Faster.

[Baruch] It’s a good answer.

[Josh] It’s the ultimate. It’s the shruggie. Where is it?

[Baruch] Yeah where —

[Josh] Cdlive again.

[Baruch] Again.

[Josh] Okay.

[Baruch] Now it builds. Hallelujah. Number one has started. Excitement.

[Josh] So now what? What does this give me?

[Baruch] So now you have it. And even if it will fail, you know, that you added back as a — as you usually do. But, but was there artifacts? […] you throw them away? You’re okay with that?

[Josh] No. I want to be able to use —

[Baruch] — You want to keep them —

[Josh] — Again, right?

[Baruch] Right.

[Josh] So this is going to production. The goal is to go to production. How do I change what I got now to just being a feedback mechanism and making my continuous integration be an actual channel direct to production?

[Baruch] First step will be keep the artifacts somewhere. Don’t throw them away.

[Josh] So —

[Baruch] You have any idea where — what can be a good repository for keeping your binary artifacts?

[Josh] Artifactory?

[Baruch] That sounds good. That’s — you guessed because of the name, right?

[Josh] Should I just —

[Baruch] Artifacts. Artifactory.

[Josh] I should just change it. Should I add the plugin? Set up the Maven release plugin?

[Baruch] So why do you want to release plugin. What’s wrong with snapshots?

[Josh] Well, so how do I — how do I release if I don’t have releases?

[Baruch] Oh yeah. Then you have the Maven release. It will fail and it will do a lot of Git stuff and it will fail again. So that — that’s how.

[Josh] So is there a difference now in the way I should think about versioning while I’m doing this?

[Baruch] You don’t want to do snapshots?

[Josh] I want to have. I want to have something that’s releasable. That’s the goal here: To have every valid build […] —

[Baruch] — Give up snapshots. Go with release versions.

[Josh] Okay.

[Baruch] And you can take build numbers as versions, how about that?

[Josh] Okay. From like Travis for example? Can I release something I can use?

[Baruch] Travis — Travis build number is a perfect release version.

[Josh] Okay. So let’s change our build here. And move this to a property. Like build dot version, which we’ll make up here.

[Baruch] That sounds good.

[Josh] And the version will be build dot version even one dot oh oh snapshot. Right?

[Baruch] Well, we don’t care about that. That’s just the fallback. If the variable not found. But it’ll be found because we will use Travis variable.

[Josh] So we’ll override this on the command line?

[Baruch] Exactly.

[Josh] When we create the Travis builds. So, in here?

[Baruch] Yes.

[Josh] Script. Maven. W minus d build. What did I say here? Build dot version.

[Baruch] Build dot version.

[Josh] Okay. Equals. I’m just going to cheat here. To want of confidence time or —

[Baruch] It’s Travis build number.

[Josh] Like this?

[Baruch] Yes. Like that. You typed it very fast.

[Josh] Copied. I’m cheating. Let’s just cheat.

[Baruch] They did not — no one noticed.

[Josh] Okay. So now I’ve got an updated build. That’ll do–

[Baruch] But still — you still didn’t deploy your artifacts. How do you plan to deploy them?

[Josh] Magic? What’s the right idea? Can I use the Maven […] plugin?

[Baruch] You can — you can. You have — you have two options. You can do the distribution management part which is standard Maven deploy plugin.

[Josh] Why not?

[Baruch] It’s good but it has two downsides. First, for it you need to config your, your username and password in settings xml in your home directory. Do you have a home directory in Travis?

[Josh] Oh yeah. Good point. No I —

[Baruch] No you don’t.

[Josh] How do I get that?

[Baruch] Good. Another. Bad. Another. Maven. Another downside will be that you’ll just deploy stupid files to Artifactory without any metadata on them. So here’s the solution for you. You can use the Artifactory Maven plugin. Artifactory Maven plugin solves both those problems. It will provide a building […] but it also give you the ability to type username and password in clear text from xml. How that sounds?

[Josh] Sweet nectar.

[Baruch] No. That sounds like a horrible idea.

[Josh] No.

[Baruch] But what you can do is use environment variables and then it’s — did you mean, did you say sweet?

[Josh] Sweet.

[Baruch] Sweet.

[Josh] Sweet.

[Baruch] That will be sweet.

[Josh] You know I — you know what my favorite part about the Maven plugin for Artifactory is?

[Baruch] Yes.

[Josh] It single-handedly lets me double the amount — doubles the lines of code in my build.

[Baruch] That’s —

[Josh] And my project actually.

[Baruch] That’s Maven magic.

[Josh] That’s Maven.

[Baruch] Any Maven plugin and then boom you have 500 lines of xml.

[Josh] Okay. You’re ready?

[Baruch] Yeah. Let’s. Oh. That. This is it. Right. All right. That’s — that’s Maven.

[Josh] Yup.

[Baruch] At its best.

[Josh] Right.

[Baruch] Like boom. And you are the top committer of today in GitHub.

[Josh] I got my […]

[Baruch] You committed the most lines of code today.

[Josh] My […]. So this is — it looks like it’s expecting an Artifactory username and Artifactory password.

[Baruch] That’s the environment variables that we’re going to use in Travis.

[Josh] Should I shut them up then?

[Baruch] Let’s add them to Travis now.

[Josh] So this worked. Which is nice.

[Baruch] Yeah, but they didn’t do anything. You throwed all of your artifacts away.

[Josh] Take off —

[Baruch] I don’t like you now. When you throw your artifacts away.

[Josh] I’m not logged in. Am I?

[Baruch] You are logged in.

[Josh] And yet, where’s the setting?

[Baruch] And yet, you don’t have options. And it is your account. You are joshlong.

[Josh] Yeah. Well, one hopes.

[Baruch] At least we hope so.

[Josh] Ah. Settings.

[Baruch] Here we go.

[Josh] Did you see that?

[Baruch] Yeah. Magic.

[Josh] Okay so. Artifactory

[Baruch] Username.

[Josh] Username equals admin.

[Baruch] Admin. Good choice.

[Josh] And cat josh emv grip Artifactory password

[Baruch] And API key. Yeah we had the API or whatever.

[Josh] Grip minus I. API. P b copy?

[Baruch] Copy. Yeah. Let’s see if it copied something. It did.

[Josh] Son of a gun.

[Baruch] Yeah. But not what we actually wanted.

[Josh] That’s okay. We can use this.

[Baruch] Yeah. No. That — okay. Yeah. Sounds good. And we use the API key that we will evoke right after.

[Josh] Right after. Even though it’s truncated we’re still going to revoke it. So, no idea.

[Baruch] It’s safe now.

[Josh] You don’t get access to my very privy, very important demo build.

[Baruch] An Artifactory instance in general but you need to change now the environment variables to Pom xml because we used the other one. Not password. But the — yeah, that one. Go. Take it to the Pom.

[Josh] So here.

[Baruch] Here. Right. Here.

[Josh] Now what?

[Baruch] Top notch. Okay. So now what we have here now let’s — let’s, let’s see what we have here. So that’s the concise Artifactory plugin. Right. And what it’s going to do. It’s going to do the publish. It will take the Travis commit. It will add metadata about the files for example. The […] which will be the Travis commit. It will go into cloud native Java Artifactory online dot com. That’s your Artifactory account from the cloud.

[Josh] Which was very generously given to me by the folks at JFrog. Wink.

[Baruch] Wink. Username and password. And we are going to put those Artifacts in leap staging local. Why in staging?

[Josh] I. I’m not sure.

[Baruch] Because we want to stage them.

[Josh] Okay.

[Baruch] How about that? Right? I love this guy. He’s so smart.

[Josh] This goes back to the idea that I make mistakes.

[Baruch] Right. And then. Exactly. And then we’re going to add some more information about the build. Like who built it. Travis. What we’ll build. What’s the build number? Build number. What the URL – the URL in Travis. Who’s the user? The user in Travis. And what was the commit. We commit it so earlier. So that’s the metadata that’s going to come from Travis, to Artifactory where it’s going to sit.

[Josh] They add and they build.

[Baruch] Yeah. So basically we are ready to put some files into Artifactory.

[Josh] I want to build and resolve my dependencies as well […].

[Baruch] Yeah, yeah. That’s — that’s a very good observation. Now where is Maven going by default to resolve the dependencies?

[Josh] Doesn’t it go to settings dot xml.

[Baruch] And, and what’s there? The default settings dot xml?

[Josh] My […].

[Baruch] Maven setting.

[Josh] Yeah.

[Baruch] Maven Central?

[Josh] Right.

[Baruch] Maven Central’s great. But we need control on the artifacts that we actually use. And that means that we need to resolve the dependencies from Artifactory.

[Josh] Right.

[Baruch] How do you do that?

[Josh] Can we just change the — oh right.

[Baruch] The settings xml. Where are the settings xml?

[Josh] In my home directory.

[Baruch] Where is your home directory?

[Josh] Doesn’t exist.

[Baruch] Doesn’t exist.

[Josh] Okay.

[Baruch] Maven. Right. The joy of Maven. So what we can do now. What we should do now, is use another Maven installation that has Artifactory baked in instead of Maven Central. How can we do that?

[Josh] Well, just so happens. That the — now I’m starting to understand why this is useful. The start dot spring dot io initializer generates a build that has a Maven wrapper preconfigured for you.

[Baruch] What’s Maven wrapper?

[Josh] Maven wrapper was inspired by the Gradle wrapper which in turn, you know, keeps a version of the build system itself. It’d be Gradle, in that case. With the code so you can version control everything. This ensures that you have reproducable builds which becomes critical when you move to continuous delivery where every build could be different and could, you know, be deployed.

[Baruch] So what we actually have here is instead of using Maven that Travis provides to us, which is the default Maven, we are using the wrapper. And one of the properties of the wrapper is which Maven to use. So we can actually change this property and say don’t use the original Maven. But instead use the Maven with the settings xml that point to our Artifactory instead of Maven central. Right?

[Josh] Like so.

[Baruch] So, we’re going to type it real fast. And just typed in everything.

[Josh] Where did this come from?

[Baruch] So what you see here is Maven that instead of coming from Apache servers comes from your Artifactory online. And the difference between the regional distribution of Maven and this distribution of Maven. Because this one comes with default settings that points to your Artifactory server.

[Josh] So we just downloaded the distro, unpacked it, changed settings dot xml, and […]

[Baruch] […] it again, put it on Artifactory. And now we have full control of which Maven is used thanks to Maven wrapper. I didn’t say anything good about Maven. It’s Gradle’s idea. They just stole it.

[Josh] But he’s, we got a bet, I’m going to make him say something nice about Maven by the end of the talk.

[Baruch] It’s a wine bet. I’m safe. Even if I lose, there is some wine here. But I’m not going to say anything good about Maven anytime soon.

[Josh] You can — we’ll see. So. So is that enough? Do we have everything we need?

[Baruch] It looks so. It looks —

[Josh] What’s going to happen when I push this?

[Baruch] So artifacts will be uploaded to Artifactory. Dependencies will be downloaded from Artifactory. Artifactory will build and they will be uploaded to Artifactory. Put a staging wrapper from we — where we could actually stage it in, I don’t know, like some cloud platform.

[Josh] Okay.

[Baruch] You have in mind any good cloud platforms.

[Josh] Sounds good. Sounds good to me. Yes. So.

[Baruch] Let’s commit it and then we’ll talk about the cloud platform.

[Josh] Git commit minus A. Build it.

[Baruch] All right. That’s — that’s a new one. The previous one was YOLO. So we are — we have some serious promise here.

[Josh] Okay, git push.

[Baruch] Okay. So let’s see that it actually kicked in. Not yet, that’s YOLO.

[Josh] Fingers crossed.

[Baruch] And we’ll get there. Still YOLO.

[Josh] Yes.

[Baruch] Here we go. All right.

[Baruch] Now let’s talk about what are we going to do with an artifact once they are in Artifactory. And we’ll verify it in a second when it — they will be there. So do you have any idea what — what can we do with them? With the Artifacts? How can you verify that they are ready for production?

[Josh] What I’d like to do is I’d like to be able to give product management, who assign me a story, an opportunity to be able to review the application once it’s there. Right?

[Baruch] The dependencies are downloaded from your Artifactory instance.

[Josh] Sweet nectar. Okay. We’re on progress.

[Baruch] All right. So sorry about that. Yeah, I interrupted you. Project management? You want to do what?

[Josh] Well, if I got to — if I got a story and I make a change and I commit that. Commit something that delivers that story, I can’t deliver to production just yet. […].

[Baruch] That’s why we’re staging.

[Josh] We’re not doing continuous deployment. We’re not doing continuous deployment, just doing continuous delivery. I want to give product management a chance to actually review the work and verify that it’s been done as expected. And then accept that.

[Baruch] How can we do that?

[Josh] Well, we could deliver this to a staging environment. Something that’s on a cloud. So I know — I happen to know a cloud that we can use. Like something like —

[Baruch] Which one?

[Josh] Cloud Foundry.

[Baruch] Cloud Foundry.

[Josh] Cloud Foundry is an open source platform as a service. I don’t know if you’ve heard of it. It’s an open source platform. It was built by folks at VMware now it’s part of Pivotal. It’s part of a foundation and other small mom and pop shops have used it as the basis for their cloud technologies. So how many of you have heard of IBM? I, B, M. Anybody.

[Baruch] No.

[Josh] Nobody?

[Baruch] No. No hands.

[Josh] What about HP? H, P.

[Baruch] No hands.

[Josh] Nobody.

[Baruch] No hand.

[Josh] What about Baidu? Baidu. Anybody?

[Baruch] Yeah. Here we go.

[Josh] There we go.

[Baruch] That’s a popular platform.

[Josh] So there we go.

[Baruch] Good.

[Josh] So, these are all small mom and pop shops that are trying to win and they’ve standardize on top of things like Cloud Foundry. So we got a — I have an account at that.

[Baruch] […]. Wait a second? Let’s see if it actually deployed. Here you have URL browsing onto — in Artifactory under, no, the next one. Next one.

[Josh] Awkward.

[Baruch] Yea. This one. Let’s look at it actually deployed. Here you go. Looking at that. You have a build. And it’s build number two.

[Josh] So beautiful.

[Baruch] You have some modules. Actually one module. What’s inside the modules? Let’s scroll down a little bit and see the information here. Okay. We have how many dependencies? Those are some of the dependencies. The artifacts that are up there. Here. Two artifacts. A jar and a jar not war.

[Josh] Yep.

[Baruch] Good decision.

[Josh] Yes.

[Baruch] And a Pom file. So we are already in Artifactory. Now let’s talk about how we take this build and to Cloud Foundry. What should we do for that?

[Josh] Let’s add. Let’s just quickly change this to have a little script that then deploys it. So we’ll say, new file. Or rather new directory. Bin. Add a new script here. And I’m gonna cf dot sh.

[Baruch] Oh my god. Bash script.

[Josh] I know.

[Baruch] You are hardcore.

[Josh] Somebody’s got to do it. Where did we keep this? We got an existing one, yeah. Desktop.

[Baruch] It’s shell script. How complicated can it be to write from scratch?

[Josh] Joshlong. No. Jbaruch.

[Baruch] That will be me. I have best scripts in my GitHub?

[Josh] You do.

[Baruch] No I don’t.

[Josh] You do.

[Baruch] It’s a lie. No.

[Josh] Where did we put it?

[Baruch] I don’t believe it.

[Josh] SwampUP. Here it is. Spring boot demo.

[Baruch] Oh my god.

[Josh] Copy.

[Baruch] You hijacked my GitHub account to put bash script in my GitHub.

[Josh] You are, at the end of the day, a distribution repository for my code. Cd bin. Touch cf dot sh. Atom cf.

[Baruch] That wasn’t my code. No. I didn’t write it.

[Josh] Okay. Git add. Whoops. Chmod ax cf dot sh. Git add. Git status. Pwd. Git commit. Adding cf. Okay.

[Josh] So now we’re going to modify our Travis to point to this script. This script is going to download the latest and greatest Linux version of the cf command line client from the repository there. And then authenticate. It will log in, authenticate, and then target. And then we can actually use cf to now push our jar. Which has been built by Travis to Cloud Foundry. So we need to now modify Travis accordantly. We’ll say at bin dot bong, although that’s cool too. Cf dot sh. That should do, yeah.

[Baruch] What about the filenames? What should be pushed?

[Josh] That’s in the — isn’t that already specified? […].

[Baruch] Yeah. It is. Question is: Is it specified correctly?

[Josh] Yeah.

[Baruch] Okay.

[Josh] There we go. […].

[Baruch] That’s super awesome.

[Josh] Yeah it is.

[Baruch] Solid.

[Josh] So. That done. Can we push it? Git status. Git commit minus A. Cloud Foundry. Git push. And if this goes to plan then it’ll be deployed after —

[Baruch] To Cloud Foundry and we’ll be able to verify and see that it actually works.

[Josh] Let’s go to the top here. Now. Come on.

[Baruch] All right. Here we go. Here we have another build. While this is building. I think we can get ready for the next stage. So let’s say the building in Cloud Foundry is solid. We got our hi message. That’s the idea of checking. Right?

[Josh] Sure.

[Baruch] And it’s good. What will be our next step?

[Josh] I should imagine we should have a big green button that says to production or to the cloud or something.

[Baruch] Okay. Sounds good. Where our — where our production a little bit. What will we do? First of all we have, of course, Cloud Foundry production environment. But also what I’ve heard is that those pesky jar files that you build are executables.

[Josh] Right.

[Baruch] So I can run them on my machine.

[Josh] Absolutely.

[Baruch] To run it on my machine I need to be able to download it on — to my machine.

[Josh] Right.

[Baruch] You want to build a download center for me?

[Josh] No.

[Baruch] No.

[Josh] I’ve got things to do.

[Baruch] Okay. So what are we going to do?

[Josh] So this Bintray thing. Talk about that.

[Baruch] Good choice. So let’s distribute those guys from Bintray. So let’s see if we have a repository in Bintray. It should be Bintray dot com slash swampUP cloud native java.

[Josh] Okay.

[Baruch] That’s an organization. And we have bunch of repositories which are pretty fine for an organization. One of them is Maven. We’re going to use that. Right? And what is the fastest way? Now that’s an open question to the cloud – to the crowd. What is the fastest way to get artifacts from Artifactory to Bintray? I didn’t ask about IBM or […]. Come on guys. Huh?

[Audience]

[Baruch] Magic is a good choice. Anybody else. Come on. We have cool tee-shirts. Thank you very much. Distribution repositories. Give this gentleman a cup of tea. Two of them. Good choice.

[Josh] A free copy of Spring.

[Baruch] Wow. You’ve been generous today.

[Josh] Yeah. Well, it’s open source.

[Baruch] Look at you. Okay, it still builds?

[Josh] So what do we do now?

[Baruch] Now let’s set up a distribution repository.

[Josh] Okay.

[Baruch] Let’s go back to Artifactory and actually create a new distribution repository for that.

[Josh] Okay. Here we go.

[Baruch] And here we go. Yeah. Let’s just create a new repository in the admin. There are no replies.

[Josh] Admin.

[Baruch] Distribution. Hit the new button.

[Josh] Authorization.

[Baruch] Yeah, we should authorize with Bintray. Cloud native Java. There I think.

[Josh] Okay. Copy this back.

[Baruch] Yeah. We have a copy button for that. That’s awesome.

[Josh] Close. Paste. Save.

[Baruch] Give it a name.

[Josh] Cdlive again. Distribution.

[Baruch] And let’s provide it with a license and the GitHub based reference here. Let’s go down. Here we go. Licenses. And.

[Josh] Apache 2.

[Baruch] Apache 2. We love Apache 2. And the CS should be your GitHub. This guy. That’s awesome. Save and finish. We’re all done.

[Josh] Okay. Now what?

[Baruch] Now, we will just — once your Cloud Foundry build will be approved. We’ll be able to — it failed.

[Josh] It failed because I forgot to add the environment variables.

[Baruch] Right. You did.

[Josh] So you can sing and dance for a minute and I’ll —

[Baruch] I’ll sing and dance. You want to do it?

[Josh] Settings.

[Baruch] Are we good with time? Not so much.

[Josh] Not so much.

[Baruch] Two minutes.

[Josh] Okay.

[Baruch] Okay.

[Josh] Let’s try.

[Baruch] You want to pretend it works or you want to do the other thing.

[Josh] You can. Yeah we can pretend. Okay, let’s pretend.

[Baruch] Okay. So we — we saw it in Cloud Foundry and it was fine. It actually, we went to the browser, and we typed the URL. And guess what we got? What we got?

[Audience]

[Baruch] Hi. It worked. People saw it live.

[Josh] Exactly.

[Baruch] People saw it. People saw it. Good. All right.

[Josh] Browser.

[Baruch] We have evidence here.

[Josh] Right.

[Baruch] That is works.

[Josh] And there it is, actually at […].

[Baruch] There is goes.

[Josh] Clear just in case.

[Baruch] All right.

[Josh] Now. Now what? […].

[Baruch] Let’s distribute.

[Josh] I forgot to include the username and password for Cloud Foundry which is something easy to do. Now.

[Baruch] Okay. Now let’s distribute. Let’s go back to our build that now is good to go. In Artifactory, we have the build now. Yeah. That’s the build one.

[Josh and Baruch] Cdlive.

[Baruch] The first one. Number two. Oh. Number three. The next one. We have a new one that we actually tested. It will be three.

[Josh] Three? Okay.

[Baruch] Right. The one when it called Cloud Foundry and was huge success.

[Josh] Right.

[Baruch] As all of us saw.

[Josh] Good.

[Baruch] And now, there’s a huge button. And can be green. Distribute. Isn’t that what we wanted?

[Josh] That’s what I wanted.

[Baruch] Big green button.

[Josh] Now what?

[Baruch] Here we go. Select the distribution repository. And hit the big green button.

[Josh] Now I can tie this to a webhook, right?

[Baruch] Yes.

[Josh] I can use that to actually trigger, for example, promotion of something from one environment to another.

[Baruch] Of course. Now once you promote it in Artifactory to Bintray, you should take it to promotion in Cloud Foundry as well. Let’s go to Bintray.

[Josh] Okay. Here we are.

[Baruch] And let’s see if we have any new packages in the Maven repository.

[Josh] Yikes.

[Baruch] You can go from here. Organizations. And then Maven repository.

[Josh] Okay.

[Baruch] And now you should see our new package. Cdlive. Inside you should see a version. Here you go. And you should see some files here under files.

[Josh] Okay.

[Baruch] It build a snapshot for us. We screwed up with environment variables again.

[Josh] Ah. Oh well.

[Baruch] Oh well.

[Josh] So that would have been build dot number.

[Baruch] Yeah. It should be —

[Josh] And what should I specify in the build here?

[Baruch] Yeah. We somewhere screwed here.

[Josh] Build dot version.

[Baruch] Yeah. That’s why.

[Josh] Son of a motherless goat.

[Baruch] Okay. You didn’t see that. It worked and it actually, here’s the cdlive version three. Not whatever this is. We’ll patch the video later.

[Josh] Yeah. It’s going to be fine. So.

[Baruch] Live demo. Dude.

[Josh] Yeah. So what did we — what did we learn? Today we looked at how to build a very simple service. We understood that if we want to get the feedback that we — that helps us build quality into it, we need to have tests. By building quality into it, and by providing a rigorous harness, we can then move that into something like Travis, which is a continuous integration server, to get validation that as we make changes things are still working against the common known baseline.

[Josh] Then we looked at how we can use this — Artifactory repository as a, sort of, center hub to sort of move things from one place to another. In this case, to production. And on the way, if we need to, we can have it visit something like a cloud environment very, very naturally.

[Baruch] And then if you plan to distribute or self-storage distribute or so from Bintray. If you want to put it on your service only, you’ll take it from Artifactory and put it on your servers.

[Josh] So what is the difference between Bintray and Artifactory, by the way?

[Baruch] Bintray’s for distribution. Artifactory’s for development. Exactly what we did.

[Josh] So Bintray, there’s no hosted, there’s no private on premise version, right?

[Baruch] It will be.

[Josh] On private?

[Baruch] Very soon.

[Josh] Really?

[Baruch] Yes.

[Josh] Bintray? I thought it was CDN and all that.

[Baruch] It is but there are huge organizations that actually want to distribute inside their organizations and they need Bintray onPrem, we will do that.

[Josh] Wow. Cool.

[Baruch] For Bundle, or IBM, or […].

[Josh] All right.

[Baruch] Okay. There is one more thing. Failing live demo hug.

[Josh] Yeah. Yeah. Aw. Sadness. Thank you so much. For your time.

[Baruch] Thank you guys.

Trusted Releases Built For Speed