Artifactory

Jfrog Index:
============
1. Why Only JFrog
2. JFrog Artifactory
3. What is Artifact
4. Source vs binary
5. Artifact Repository
6. Why artifact Repository
7. Type of packages it supports
8. How to set up Artifactory server on AWS
9. Artifact Deployment from Maven to JFrog
10.Artifactory Integration with Jenkins

repository management tool
===========================
 - Repository management tools helps development teams create, maintain, and track their software packages.

Options
-------
1. Jfrog Artifact
2. Nexus
3. Apache Archiva
4. Nuget
5. github
6. YUM,RPM,npm,playstore,applestore...etc is a package mgmt tools

Why Only Jfrog
--------------
jfrog supports wide range of formets and types.
Eg:- 
     python repo
     chef repo
     puppet repo
     Apt repo
     yum repo
     docker repo
     rpm repo
     maven repo...etc

- it is a repository management tool
- A universal artifact repository manager
- JFrog Artifactory is a repository manager that supports all available software package types
- Artifactory, the first-in-class binary repository management

Jfrog Artifactory?
==================
Jfrog Artifactory is a tool used in devops methodology to store artifacts (readily deployable code)

What is Artifact
----------------
The files that contain both compiled code and resources that are used to compile them are know as artifact. 
- They are readily deployable files.
								     	
- source code  -->  Build Tools  -->  Compilation  -->  Binary code -->  Dependencys/resources -->  Artifact

- in java an artifacts would be jar, war, ear...etc file
- in .net an artifacts would be .dll file

Source:-                             Binary
-------                              ------
1. text                    <--->    Blob(raw data)
2. we compare two source files   <--->   we cannot compare two source files.               
3. based on the content we can version it   <--->   we version it by name
4. stored by override.         <--->   not stored by override

 								    	 
what is artifact Repository?
----------------------------
- An artifact repository is a repository which can store multiple different versions of artifacts.each
  time the war or tar.gz file is created. it stored in a server dedicated for the artifacts.

why artifact Repository?
------------------------

 source code  --> Compilation  -->  Test  -->  Review  -->  Successful  -->  Deploy

in real-time in the above process if you have any error in test env, we will rollback to version control to fix it. instead of that if you store artifacts in repo we can rollback to prevision version.

Author
------
https://jfrog.com
- they have number of products like 
    - Jfrog Artifactory (Very Popular)
    - Jfrog Pipelines
    - Jfrog x-ray
    - Jfrog connect
    - JFrog Container Registry ...etc
 
Written in
------------
- Jfrog developed in java. it is platform independent(run in windows, mac, Linux)

Releases
--------
- Free, Professional and Enterprice

Free vs Pro
-----------
	https://www.jfrog.com/confluence/display/JFROG/Artifactory+Comparison+Matrix

Type of packages it supports:
-----------------------------
	https://www.jfrog.com/confluence/display/JFROG/Package+Management
Note:- what kind of repo = what kind of package


 How to setup Artifactory server in AWS 
---------------------------------------

1. Pre-requisites:
   An AWS T2.small EC2 instance (Linux)
   Open port 8081 and 8082 in the security group

2. install Java(openJdk)
    - /usr/sbin/alternatives --config java
     Note:- it'll show you how many java versions are installed in your machine and you can select which one want to use.
    - sudo su - root (or) sudo su - (or) sudo -i
    - yum install java-17-openjdk-devel
    - java and javac (Java Compiler)
    - java -version
    - which java
    - whereis java
    - ls -l /usr/bin/java
    - ls -l /etc/alternatives/java
    - java path --->> /usr/lib/jvm/jre-17-openjdk-17.0.5.0.8-2.el9_0.x86_64/bin/java
    - yum list installed | grep java

3. Download Artifactory packages onto /opt/
	For Latest version of Artifactory OSS    https://jfrog.com/community/open-source/
	For Older version of Artifactory OSS     https://jfrog.bintray.com/artifactory/ (Recommended Stable Version)

4.   Download Artifactory package into /opt/  
       # cd /opt 
       # wget https://jfrog.bintray.com/artifactory/jfrog-artifactory-oss-6.9.6.zip (Recommended Stable Version)

5. extract artifactory tar.gz file
       # unzip jfrog-artifactory-oss-6.9.6.zip
         note:- install unzip package if unzip command is not working " yum install unzip -y"

6. Go inside to bin directory and start the services
       # cd app/opt/jfrog-artifactory-oss-6.9.6/bin
       # bash artifactory.sh (or) ./artifactory.sh start
7. access artifactory from browser

     http://<PUBLIC_IP_Address>:8081



Artifact Deployment from maven to Jfrog
=======================================

1. Add Deployment element to maven pom.xml file.
 <distributionManagement>
    <repository>
        <id>central</id>
        <name>Vinodh-Machireddy-Tutorials</name>
        <url>http://34.238.157.19:8081/artifactory/vmtutes-repo</url>
    </repository>
    <snapshotRepository>
        <id>central</id>
        <name>Vinodh-Machireddy-Tutorials</name>
        <url>http://34.238.157.19:8081/artifactory/vmtutes-repo</url>
    </snapshotRepository>
</distributionManagement>

2. Add Jfrog Credentials to apache-maven-3.8.6 settings.xml file.
	<servers>
	    <server>
      		<id>vmtutes</id>
      		<username>admin</username>
      		<password>Vmtutes_123</password>
    	    </server>
	</servers>

3. Navigate to maven structure where pom.xml and src locates, and give below command.
    - mvn Deploy


Artifactory Integration with jenkins
=====================================

pre-requisites

A Artifactory server
A Jenkins Server

Integration Steps

Login to Jenkins to integrate Artifactory with Jenkins

1. Install "Artifactory" plug-in
     Manage Jenkins -> Jenkins Plugins -> available -> artifactory
2. Configure Artifactory server credentials
     Manage Jenkins -> Configure System -> Artifactory (or) Jfrog
3. Artifactory Servers
	Server ID : VmTutes
	URL : Artifactory Server URL (http://localhost:8081/)
	Username : admin
	Password : default password is "password" only. (login with default password later you can change)
        Test the connection


Create a Freestyle Project

- Create a new job
    ->  Job Name : VmTutes-Job
- Source code management
    ->  Github URL : https://github.com/VmTutes/jfrog.git
- Build Environment
    ->  Maven3-Artifactory Integration : `<provide Artifactory server and repository details
- Build --> Invoke Artifactory Maven3
- Goals: clean deploy
- Execute job


# Create a Maven Project(Optional)

- Create a new job
    ->. Job Name : VmTutes-Job
- Source code management
    ->  Github URL : https://github.com/VmTutes/jfrog.git
- Build Environment(optional)
    ->  Resolve artifacts from Artifactory : <provide Artifactory server and repository details>
- Build - Goals: clean install
    ->. Post-build Actions
- Deploy Artifacts to Artifactory : <provide Artifactory server and repository details>
- Execute job
 

To Custom Base URL:- Administrator --> General --> Settings
To create new user:- Administrator --> User Management --> Users


 <build>
    <plugins>
        <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>3.0.0-M1</version>
        </plugin>
    </plugins>
</build>


		           				 =========THE END=======
	
			              +91-7204143230(WhatsApp/Call), Email:- [email protected]