DevOps CI/CD | Jenkins Code to Dynamically Choose Snapshot Or Release |Jenkins Pipeline Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello guys were able to push maven artifacts to Nexus but we are not segregating them into release and snapshot release and snapshot is maven Convention the idea is if any of the version is ending with slap shot it is snapshot version snapshot in sense this is currently in development and if we take out snapshot extension to the version it actually mean its release version it is ready to release and there won't be any more changes to same release version in future in case if this release has any defects it's going to be fixed in the next version but not in the same version and one more thing to notice we have created simple app release repository this repository will accept ok the versions basically release versions so in case of continuous integration in DevOps if I try to push same version second time this will reject and our build gets failed I need to say when our sprint is active and new features are added by different developers and we have congeals integration going on usually that happens on a single washing correct when we start a new sprint we will mark this new version as a snapshot say if we are a starting newsprint which is let's say 3.0 and when we began newsprint we need to mark it as snapshot because if I don't mark it as snapshot if I build this same version three times or four times what happens here it is actually landing into release version and in Nexis release version once you push let's say three point zero point zero when you again push next time it fails let me show that in action let's login to our Jenkins mission you let me okay open our essence lat go to configure all right so we are pulling out our application from here let's open palm file see current version here is two point zero point zero this version is already there in our release right two point zero point zero if I build this application again if I build this application again if you see our jenkins file it is pushing that to release for right it's pushing that to release I said two point zero point zero is already there in our release second time if I push same version it won't accept let's try to do that by building this job let's build it see that build got failed uploading this version got failed okay it says the specific repository were uploading it doesn't allow for updating assets right so when they have a new sprint when we have a new sprint in pom dot XML what we have to do is we have to make this as a snapshot such that such that in my Jenkins file what I will do is what I will do is if it is snapshot I will point this one to snapshot in case of snapshot it accepts multiple snapshots of same version so when we are in development we will not change the version for every new build correct so the version will only change when we start a new release but for this release water washing we incremented that remains same until we complete and release this to the customer so when we begin a new sprint will make version a snapshot in pom that XML number one and we will push those Russians to snapshot not to the release okay let me go over our Nexus go to settings repositories along with release I need a repository for snapshots should be in maven hostage let's name that snapshot so Russian policy it is a snapshot so I'm I want to leave other details as default and create this repository I want to use this specific repository for storing my snapshot questions good coming back to our Jenkins pipeline shop right so I need to dynamically decide where my artifact should go if it is released it should go to release if it is snapshot it should go to snapshot so under this script okay so from maven I can't read the ocean I say Nexxus rapper name equals see that yeah I will check if Russian ends with snapshot I'm using ternary operator if version ends with snapshot I need to return snapshot repository name as an to written release repository name okay see if it is ending with snapshot it has to be snapshot otherwise it has to be released now take that information I sit here we fixed our Jenkins pipeline code let's assume we are starting newsprint which is three point three point zero so until this friend completes I will maintain this as a snapshot such that in my logic I am checking for the version ends with snapshot if it is true I will push mark to fax to snapshot because snapshot accepts multiple snapshots of same version so once I am done with my sprint activities once it is tested and ready for release we need to remove this snapshot and such that the same code will use release version and it uploads artifacts to release repository all right our Jenkins pipeline code got changed and also they are starting new release and that new release is three point zero point zero - snapshot let's push this code to our gate repository and trigger the job and make sure what we implemented is working according to our requirements as open the terminal I would say Teresa did add Jenkins and you you that is call this snapshot fix and push it now let me cross check our implementations there yeah so go back to our Jenkins job build it because Russian is ending with snapshot obviously the artifacts needs to be pushed the snapshot now build got success let me take you through Nexus go to browse check simple app snapshot could notice that three point zero point zero appended with a timestamp if I do an X build also which will have three point zero point zero as a snapshot question it won't fail built so that's how we usually deal with snapshot versions in real time it got succeeded again refresh and you see there is one more snapshot of three point zero point zero which is rendered bits some sort of timestamp there so after we finish all our sprint activities we need to remove that snapshot which becomes release and this version gets into release repository so release should contain only the artifacts which are ready to release and which will never change I mean the same version will never change again if there are defects in same version we need to come up with something like this and push it again to the release version
Info
Channel: Java Home Cloud
Views: 12,302
Rating: undefined out of 5
Keywords: java home, devops, java home cloud, devops tutorial, devops by javahome, devops by java home cloud, nexus release vs snapshot, jenkins pipeline tutorial, jenkins pipeline tutorial for beginners nexus snapshot repository, jenkins pipeline as code, jenkins pipeline by java home, jenkins dynamically use snapshot and release repositories, what is maven snapshot version, what is maven release version.
Id: Unsa7Ax6kQA
Channel Id: undefined
Length: 11min 30sec (690 seconds)
Published: Fri Feb 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.