Skip to main content

Jenkins with sonarqube and nexus

 Jenkins installation on redhat machine


installation of java on 


 yum install wget -y

 yum install java-1.8.0-openjdk-devel.x86_64


Jenkins nstallation

-----------------------

i.  sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

ii. sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

iii.sudo yum install jenkins

iv. service jenkins start 

service jenkins status




====================sonarqube setup==========


Sonarqube on amazon linux ec2 machine


Install docker on amazonlinux ec2 then run below command


docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest



=====Integration of sonarqube and jenkins================================



-----In jenkins we need to install

SonarQube Scanner plugin---


Then go to manage jenkins and click on configure system


In middle we have SonarQube servers option will be there


clcik on Add sonar


give name and url


http://44.192.26.91:9000


clcik on add we will go jenkins home 


under kind we need to select secret text


In secret we need to give token


select secret text under none



---go to jenkins ec2 machine-----


[root@ip-172-31-70-222 ~]# cd /var/lib/jenkins/tools/

 we will see 


[root@ip-172-31-70-222 tools]# ls

hudson.tasks.Maven_MavenInstallation


[root@ip-172-31-70-222 tools]# cd hudson.tasks.Maven_MavenInstallation/



[root@ip-172-31-70-222 hudson.tasks.Maven_MavenInstallation]# cd maven

[root@ip-172-31-70-222 maven]# ls

bin  boot  conf  lib  LICENSE  NOTICE  README.txt

[root@ip-172-31-70-222 maven]# cd conf/

[root@ip-172-31-70-222 conf]# ls

logging  settings.xml  toolchains.xml



[root@ip-172-31-70-222 conf]# vi settings.xml



 <server>

      <id>deploymentRepo</id>

      <username>repouser</username>

      <password>repopwd</password>

    </server>

    -->


    <!-- Another sample, using keys to authenticate.

    <server>

      <id>siteServer</id>

      <privateKey>/path/to/private/key</privateKey>

      <passphrase>optional; leave empty if not used.</passphrase>

    </server>

    -->

    <server>

      <id>deploymentRepo</id>

      <username>repouser</username>

      <password>repopwd</password>

    </server>



======================change above into below =======


 <server>

      <id>nexusRepo</id>

      <username>admin</username>

      <password>1234567890</password>

    </server>

-----------------------------------------------------------


Go to our github project url then click on pom.xml and edit that one 


with ourl sonarqube url and token


<sonar.host.url>http://44.192.26.91:9000/</sonar.host.url>

                 <sonar.login>96dbe2289a027feb64d83ab11bbc7cc3b22ed5e2</sonar.login>







Comments

Popular posts from this blog

How to copy files from one server to another server by using ansible copy module

 We have two servers 1.master 2.worker1 create playbook example: play.yml ---   - hosts: all     tasks:     - name: Ansible copy file to remote server       copy:        src: ~/kube-cluster        dest: /root Run ansible playbook  ansible-playbook play.yml

Kubernetes interview questions and answers

1.H ow to setup kubernetes dashboard on ubuntu16.04 cluster? To create kubernetes dashboard follow below link https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html To deploy the Metrics Server kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml kubectl get deployment metrics-server -n kube-system Deploy the dashboard kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml root@ip-172-31-43-76:~# kubectl get svc -n kubernetes-dashboard NAME                        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)         AGE dashboard-metrics-scraper   ClusterIP   10.102.6.123   <none>        8000/TCP        120m kubernetes-dashboard  ...

How to create a user in kubernetes cluster and assign read only permissions

root@ip-172-31-16-42:~# kubectl get secrets NAME                  TYPE                                  DATA   AGE default-token-2m258   kubernetes.io/service-account-token   3      48m root@ip-172-31-16-42:~ # kubectl create serviceaccount readonlyuser serviceaccount/readonlyuser created root@ip-172-31-16-42:~# kubectl create clusterrole readonlyuser --verb=get --verb=list --verb=watch --resource=pods clusterrole.rbac.authorization.k8s.io/readonlyuser created root@ip-172-31-16-42:~ # kubectl create clusterrolebinding readonlyuser --serviceaccount=default:readonlyuser --clusterrole=readonlyuser clusterrolebinding.rbac.authorization.k8s.io/readonlyuser created root@ip-172-31-16-42:~# TOKEN=$(kubectl describe secrets "$(kubectl describe serviceaccount readonlyuser | grep -i Tokens | awk '{print $2}')" | g...