Create an Ubuntu server in AWS for Jenkins, SonarQube, and Nexus
Instance: t2.large
Memory: 40GB
sudo apt-get updatesudo apt install openjdk-17-jdkcurl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
sudo systemctl start jenkinssudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivysudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt-get update
sudo apt-get install docker-ceGo to Jenkins → Manage Plugins → Install the following plugins:
- SonarQube Scanner
- Config File Provider
- Maven Integration
- Pipeline Maven Integration
- Nexus Artifact Uploader
- Docker
- OWASP Dependency-Check
- Docker Pipeline
- Eclipse Temurin Installer
- Pipeline Stage View
sudo docker run -d -p 8082:8082 sonatype/nexus3- Sign in to Nexus:
Username:admin
Retrieve the password:sudo docker exec -it <container-id> /bin/bash cd sonatype-work/nexus3 cat admin.password
- Copy the password (do not include
bash). - Add Nexus URL in pom.xml
Login to Nexus --> browse --> copy maven releases and maven snapshots ---> paste in URL added in pom.xml
Edit pom.xml
- Create gloabl maven configuration in jenkins managed files
Goto managed files --> add new config --> select Global Maven settings.xml --> give ID as Global-maven --> add below config under server --> username and password of nexus
-->
<server>
<id>maven-releases</id>
<username>admin</username>
<password>kirancgwd</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>kirancgwd</password>
</server>
-->
docker run -d --name sonar -p 9000:9000 --restart=always sonarqube:latest- Login:
Username:admin
Password:admin - Generate a token in SonarQube and configure the SonarQube server in Jenkins.
Add credentials for:
- Git (if private)
- Docker
- SonarQube
Configure the following tools in Jenkins:
- JDK
- Docker
- Maven
- SonarQube
- OWASP
- Write a Declarative pipeline script using Jenkinsfile.
- Ensure tools are defined in the pipeline with names matching the Jenkins configuration.
- Define all tools explicitly in the pipeline script.
- Tool names in the pipeline must match the names defined in Jenkins.

