Thursday, 17 September 2020

Slack as a Devops Tool/Integrating Slack with jenkins








 

DevOps aims to increase the communication and collaboration between Development and Operations teams in the workplace. However, this communication ideal can be hard to fully execute.  

 Many organizations traditionally use email for any internal communication. However, this is difficult to maintain in a fast-paced development environment. There are numerous problems that can arise from using email: people don’t see the emails or see them too late, people forget to respond in a timely manner or never respond at allOne single place where teams can come together to discuss the Development Lifecycle is extremely beneficial to organizations

Many enterprise organizations are now turning to the platform Slack in order to increase communication in the workplace

Use Slack with DevOps Applications 

Slack has the capability to integrate with several of the most popular DevOps tools, such as GitHub, Jenkins CI, Jira, and Azure Pipelines. Inedo’s BuildMaster is also able to integrate with Slack.  Slack is able to integrate seamlessly into the existing development toolchain, making it easier to identify and remedy any builds, errors, or general problems that might occur.  

How to integrate Slack with Jenkins? You need to install slack notifications plug-in in Jenkins.



Pre-requistes:
Install Slack notifications plug-in




Steps to integrate Slack with Jenkins:

1. Go to www.slack.com and signup with your email, create your workspace.
2. Create a channel in Slack.



3.  --> Click connect an app




4. enter Jenkins CI and choose that.





5. Click on Add configuration
6. Add Jenkins CI configuration and select the channel from the drop down.





7. once you added, you will see the below page:





8. Now navigate to Jenkins, Manage Jenkins --> Configure System. Under Global Slack notifier settings. Enter the Team Subdomain value as workspace. Also provide channel name based on what you created. Also provide the token info as well




Token info can be entered by click on Add credentials, Choose secret text drop down and enter token in password text box.









 
9. Now to your Job in Jenkins, Click on Configure.  Click on add post build action. select desired settings. 






10. Click on Apply, and Save

11. Click on Build Now, Now you will see results in Slack channel.


How to integrate Artifactory to Jenkins and publish artifact to Artifactory

 

Integrate Artifactory with Jenkins - Upload Artifacts from Jenkins to Artifactory - How to Integrate Jenkins with Artifactory

You can install plug-in called Artifact plug-in to integrate Artifactory with Jenkins. Let us see how to integrate Jenkins with Artifactory and able to upload War/Ear/Jar/Exe/DLLs using Maven.




Pre-requistes:
Install Artifactory plugin in Jenkins.



Make sure Maven 3 is also configured under Manage Jenkins--> Global Tool configuration
Enter Name as Maven3
/usr/share/maven as MAVEN_HOME



Configure Arifactory in Jenkins:
1. Go to Manage Jenkins, Click on configure system. Look for Artifactory section, click on Add Artifactory server



2. Enter Artifactory url like given below:
some name for server_id
http://public_dns_name:8082
admin/Admin123 as credentials
Click on Test connection to verify everything is right.
You should get the message like below:
Found Artifactory 7.4.1



Apply...Save

3. Once you installed the above plug-in, click on existing Freestyle job configuration.
4. Go under Build environment
Select Maven 3 - Artifactory integration check box
and click on refresh Repositories and choose repos as mentioned below:







 5.Click on Add Build step and choose Invoke Artifactory Maven 3



6. Enter value as below, MyWebApp/pom.xml as root POM
and goal as install




Apply....Save
7. Now click on Build, Jenkins should build using Maven and upload WAR file into Artifactory.

8. Login to Artifactory, Click on Artifactory --> Packages



How to Install Jfrog Artifactory on Ubuntu 20/18,Pro,Oss,Linux Archive, Debian, RPN,Docker

 This brief tutorial shows students and new users how to install JFrog Artifactory on Ubuntu 18.04 | 16.04.

JFrog Artifactory is cross-platform software that allows DevOps to manage multiple package repositories, hosted locally or in the cloud from a single platform.

JFrog Artifactory can integrates with your current environment, providing high availability with active/active clustering and multi-site replication to automate your pipeline and enable faster releases.

For more about JFrog Artifactory, please visit its homepage.

If you’re a student or new user looking for a Linux system to learn on, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.and other device.

While learning Ubuntu, you will find that Linux isn’t so different than Windows and other operating systems in so many ways, especially when it comes to using the system to get work done.

To get started with installing JFrog Artifactory, follow the steps below:

Pre-requistes:

Install Artifactory on 2GM RAM, for AWS choose at least small or medium instance type.

Default ports 8081 and 8082 needs to be opened.

8081 for Artifactory REST APIs.

8082 for everything else (UI, and all other product’s APIs).


Step 1: Prepare Ubuntu

Before installing packages on Ubuntu, you must first update the server. To do that, run the commands below:

sudo apt update
sudo apt dist-upgrade
sudo apt autoremove

Running the commands above will update the remove obsolete packages from your system. It’s also a good to reboot the server after running the above commands.

Step 2: Install OpenJDK 8

To properly use JFrog Artifactory, you will need Java installed. First, download the Java 8 Development Kit: either the official Oracle JDK or Open JDK

For this tutorial, we’re going to be install OpenJDK.

To do that, run the commands below:

sudo apt update
sudo apt-get install openjdk-8-jdk openjdk-8-doc

After installing Java, you can verify it by running the commands below:

java -version

It should output something similar as shown below:

Output:
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

Now that you have updated and installed Java, continue below to installing JFrog.

Step 3: Download and Install JFrog Artifactory

The quickest and easiest way to get JFrog installed is via a APT repository. Installing JFrog from the repository will allow you to always get the latest updates as they’re released.

To install, follow the steps below:

 echo "deb https://releases.jfrog.io/artifactory/artifactory-debs bionic main" | sudo tee -a /etc/apt/sources.list.d/jfrog.list
 wget -qO - https://releases.jfrog.io/artifactory/api/gpg/key/public | sudo apt-key add -
 sudo apt update
 sudo apt install jfrog-artifactory-oss
 sudo systemctl start artifactory
 sudo systemctl enable artifactory
 sudo systemctl status artifactory



It should output similar lines as shown below:

artifactory.service - Artifactory service
   Loaded: loaded (/lib/systemd/system/artifactory.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-03-26 20:34:28 CDT; 3s ago
  Process: 6249 ExecStart=/opt/jfrog/artifactory/app/bin/artifactoryManage.sh start (code=exited, status=0/SUCCESS)
 Main PID: 8345 (java)
    Tasks: 0 (limit: 4666)
   CGroup: /system.slice/artifactory.service
           ‣ 8345 /opt/jfrog/artifactory/app/third-party/java/bin/java -Djava.util.logging.config.file=/opt/jfrog/artifacto

Mar 26 20:34:28 ubuntu1804 artifactoryManage.sh[6249]: metadata started. PID: 8924
Mar 26 20:34:28 ubuntu1804 su[8792]: pam_unix(su:session): session closed for user artifactory
Mar 26 20:34:28 ubuntu1804 su[8931]: Successful su for artifactory by root

Check if service is running locally on 8081 port

Enter

curl localhost:8081

Step 4: Access Artifactory Portal

When you’re done installing, open your web browser and browser to the server’s hostname or IP address as shown below:

http://ip_dns_name:8081/artifactory/

You should see the login portal similar to the one below:

Jfrog Artifatory Ubuntu

Login with Username:  admin and Password: password

You’ll be prompted to change the temporary password above.

You can enter:admin123/admin123

Skip for base URL and skip proxy setup, choose Generic and Maven

Click Next

JFrog Artifactory

Enjoy!

For other Platforms see the complete instruction below:

Artifactory OSS Install in Linux Manually


$ cd /opt/
$ wget https://releases.jfrog.io/artifactory/bintray-artifactory/org/artifactory/oss/jfrog-artifactory-oss/7.21.5/jfrog-artifactory-oss-7.21.5-linux.tar.gz
$ cd artifactory-pro-7.21.5
$ cd app/bin
$ ./artifactory.sh start

# BROWSE - http://15.207.221.219:8082
# Username/Password - admin/password

Artifactory Pro Install in Linux Manually


$ cd /opt/
$ wget https://releases.jfrog.io/artifactory/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/7.23.3/jfrog-artifactory-pro-7.23.3-linux.tar.gz
$ tar -zxvf jfrog-artifactory-pro-7.23.3-linux.tar.gz
$ cd jfrog-artifactory-pro-7.23.3
$ cd app/bin
$ ./artifactory.sh start

$ ./artifactory.sh status
Using default router's certificate and private key
router is running (PID: 10621)

metadata is running (PID: 10767)
event is running (PID: 10878)
frontend is running (PID: 10994)
Artifactory is running, on pid=11080

# BROWSE - http://15.207.221.219:8082
# Username/Password - admin/password

Artifactory Pro Install in Linux using Debian Package


# To determine your distribution, run lsb_release -c or cat /etc/os-release
# Example:echo "deb https://releases.jfrog.io/artifactory/artifactory-pro-debs xenial main" | sudo tee -a /etc/apt/sources.list;
wget -qO - https://releases.jfrog.io/artifactory/api/gpg/key/public | sudo apt-key add -;
echo "deb https://releases.jfrog.io/artifactory/artifactory-pro-debs xenial main" | sudo tee -a /etc/apt/sources.list;
sudo apt-get update && sudo apt-get install jfrog-artifactory-pro
deb https://releases.jfrog.io/artifactory/artifactory-pro-debs xenial main

Start Artifactory with:
$ systemctl start artifactory.service

Check Artifactory status with:
$ systemctl status artifactory.service

Installation directory was set to /opt/jfrog/artifactory
You can find more information in the log directory /opt/jfrog/artifactory/var/log
System configuration templates can be found under /opt/jfrog/artifactory/var/etc
Copy any configuration you want to modify from the template to /opt/jfrog/artifactory/var/etc/system.yaml

Artifactory OSS Install in Linux using Docker


$ docker run -p 8081:8081 -p 8082:8082 -d releases-docker.jfrog.io/jfrog/artifactory-oss:latest
# BROWSE - http://15.207.221.219:8082
# Username/Password - admin/password

Artifactory Pro Install in Linux using Docker


$ docker run -p 8081:8081 -p 8082:8082 -d releases-docker.jfrog.io/jfrog/artifactory-pro:latest
# BROWSE - http://15.207.221.219:8082
# Username/Password - admin/password

BELOW ARE OLD VERSION – ARCHIVED

 
 
Download and Install JDK 8 using RPM
$ yum install wget -y

$ wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" 

amp;source=gmail&ust=1538578811202000&usg=AFQjCNFTog2RTpP6vJg7vCwY_Ya7woleIg”>http://download.oracle.com/otn-pub/java/jdk/8u131-$ b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm

rpm -Uvh jdk-8u131-linux-x64.rpm

 
RPM File – Download, Install & Run Artifactory Pro
Download PRO
wget https://bintray.com/jfrog/artifactory-pro-rpms/rpm -O bintray-jfrog-artifactory-pro-rpms.repo

sudo mv bintray-jfrog-artifactory-pro-rpms.repo /etc/yum.repos.d/

sudo yum install jfrog-artifactory-pro
 
Zip File – Download, Install & Run Artifactory Pro
$ wget https://bintray.com/api/ui/download/jfrog/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/6.1.0/jfrog-artifactory-pro-6.1.0.zip
 
RPM File – Download, Install & Run Artifactory OSS
wget https://bintray.com/jfrog/artifactory-rpms/rpm -O bintray-jfrog-artifactory-rpms.repo

sudo mv bintray-jfrog-artifactory-rpms.repo /etc/yum.repos.d/

sudo yum install jfrog-artifactory-oss
 
Zip File – Download, Install & Run Artifactory OSS
$ wget https://bintray.com/jfrog/artifactory/download_file?file_path=jfrog-artifactory-oss-6.1.0.zip
 
RPM File – Download, Install & Run Artifactory CE
wget https://bintray.com/jfrog/artifactory-rpms/rpm -O bintray-jfrog-artifactory-rpms.repo

sudo mv bintray-jfrog-artifactory-rpms.repo /etc/yum.repos.d/

sudo yum install jfrog-artifactory-cpp-ce
 
Zip File – Download, Install & Run Artifactory CE
$ wget https://bintray.com/jfrog/artifactory/download_file?file_path=jfrog-artifactory-cpp-ce-6.1.0.zip
 
To Understand the directory structure.
https://www.jfrog.com/confluence/display/RTF4X/Installing+on+Linux+Solaris+or+Mac+OS#InstallingonLinuxSolarisorMacOS-RPMorDebianInstallation
 
To Run Artifactory – start manually
/opt/jfrog/artifactory/bin/artifactory.sh
 
To Run Artifactory – start as a daemon
/opt/jfrog/artifactory/bin/artifactoryctl start

/opt/jfrog/artifactory/bin/artifactoryctl check

/opt/jfrog/artifactory/bin/artifactoryctl stop
 
To Run Artifactory – install Artifactory as a service
/opt/jfrog/artifactory/bin/installService.sh

systemctl status artifactory.service

systemctl start artifactory.service

systemctl stop artifactory.service


Docker Way: Pull docker image of artifactory pro
docker login -u usernmae -p 543a181849465b127327a92231f63b321980f1fb jfrog-docker-reg2.bintray.io

docker pull jfrog-docker-reg2.bintray.io/jfrog/artifactory-pro:6.1.0

docker run -d -p 8081:8081 jfrog-docker-reg2.bintray.io/jfrog/artifactory-pro:6.1.0

# Wait for "Artifactory successfully started" using below commands.

docker logs cont-id

http://x.x.x.x:8081/artifactory

admin/password
 
Docker Way: Pull docker image of artifactory OSS
docker login -u usernmae -p 543a181849465b127327a92231f63b321980f1fb jfrog-docker-reg2.bintray.io

docker pull jfrog-docker-reg2.bintray.io/jfrog/artifactory-oss:6.1.0

docker run -d -p 8081:8081 jfrog-docker-reg2.bintray.io/jfrog/artifactory-oss:6.1.0

# Wait for "Artifactory successfully started" using below commands.

docker logs cont-id

http://x.x.x.x.134:8081/artifactory

admin/password
 
Docker Way: Pull docker image of artifactory CE
docker login -u usernmae -p 543a181849465b127327a92231f63b321980f1fb jfrog-docker-reg2.bintray.io

docker pull jfrog-docker-reg2.bintray.io/jfrog/artifactory-cpp-ce:6.1.0

docker run -d -p 8081:8081 jfrog-docker-reg2.bintray.io/jfrog/artifactory-cpp-ce:6.1.0

# Wait for "Artifactory successfully started" using below commands.

docker logs cont-id

How to Specify Particular Jenkins Agent(Slave) to Build jobs

 When you have multiple agent available, whether you are using a classic job type (Freestyle, Maven, etc) or a Pipeline (even Multibranch Pipeline), you can select a specific agent to build your project.

In a classic job type, you will find a Restrict where this project can be run checkbox and text field in the properties of the job



In a (Multibranch) Pipeline, you can specify this in the parameter of the node block:

node('foo') {}

The value of both the text field and the node parameter are the same: it can be the agent name, or a Groovy boolean expression.

Using the agent name, you make the job tied to this specific agent. This can be problematic when the build load grow, your agent becomes less and less available.

The best solution is to use the labels. When you configure your agents, you can put a space-separated list of labels on your agent. Those can be used to describe what the agent can be used for: mavennpm, etc. It can also describe what the agent is running on: windowslinuxx64, etc. This will create pools of agents based on the labels. Then, on your job configuration, you can use those label in a Groovy boolean expression to select the correct agent for your job:

  • “I need an agent running on linux”: linux
  • “I need an agent running on windows with maven”: windows && maven
  • “I need an agent with a jdk-8 and running either on windows x32 or linux x64”: jdk-8 && ((windows && x32) || (linux && x64))

The expression can be as complex as you need. However, the expression cannot be a regexp. It can only be a boolean expression.





How to upgrade Maven

  java.lang.IllegalStateException I had installed maven in my ubuntu using command  apt install maven This installed maven in path /usr/shar...