Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven style #4

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Crash log files
crash.log



# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
Expand All @@ -27,3 +29,34 @@ override.tf.json

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Created by https://www.toptal.com/developers/gitignore/api/java
# Edit at https://www.toptal.com/developers/gitignore?templates=java

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# End of https://www.toptal.com/developers/gitignore/api/java
34 changes: 34 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>my-app</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1675155637774</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
152 changes: 86 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,107 @@
# Jenkins-cicd
PG DO - CI/CD Pipeline with Jenkins Simplilearn

# AWS Ubuntu VM Provisioning steps
- Step 1: Click on Launch Instance
- Step 2 : Click on Software Image (AMI)
- Select Ubuntu
- Step 4: Key pair name – required
- Click on Create new key pair
- Put key pair name Jenkins-sl
- & Download it
- Step 5 : Click on Launch Instance
- Step 6 : Select your VM and Click connect
- Step 7 : You can see the terminal
- Step: Showing Github example

# Git Status
```
git --version
```
## cretae Dir
```
mkdir demo
cd demo
```
## GIT & Ubuntu SSH connection
```
ssh-keygen
# Java
## References:
- https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html


⦁ Build with Maven option in jenkins

⦁ pom.xml file required

"Hit enter button 3 time"
⦁ Commands

# Creating a Project
You need somewhere for your project to reside. Create a directory somewhere and start a shell in that directory. On your command line, execute the following Maven goal:

cat ~/.ssh/id_rsa.pub
git clone [email protected]:manikcloud/Jenkins-cicd.git
history
history | cut -c 8-
```
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

# JENKINS INSTALLATION on UBUNTU 18.04, for Ubunt 22.04 please skip the step 3 & 4
```
sudo apt-get update
sudo apt install openjdk-8-jdk
sudo wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt install jenkins
sudo /etc/init.d/jenkins start
service jenkins status
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
history | cut -c 8-

You will notice that the generate goal created a directory with the same name given as the artifactId. Change into that directory.

```
# Jenkins URL with port 8080
- http://x.x.x.x:8080/
cd my-app

replace x with your ip
```

# Change Security group rule for Jenkins
## Build the Project
```
- Select your instance
- Down below select your security tab
- Click on the Security groups sg-0c51908b5fa4abf75 (launch-wizard-2)
- Click on the action
- Click on EDIT INBOUND RULE
- Select custom TCP and put port 8080
- Custom ip should be 0.0.0.0/0
- Click on Save the rule
mvn package

```

# common error
- validate
- generate-sources
- process-sources
- generate-resources
- process-resources
- compile


You may test the newly compiled and packaged JAR with the following command:
```
getting "E: Unable to locate package openjdk-8-jdk" message on java update
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
Which will print the quintessential:
```
Hello World!

# Lesson 3 Demo 3: Maven Setup

This section will guide you to:
⦁ Configure build tools and JDK versions

# Resolution
Run this command
This lab has two sub-sections, namely:
⦁ Configuring the Maven setup
⦁ Configuring the JDK

## Step 1: Configuring the Maven setup
⦁ Open the terminal and go to Jenkins dashboard by typing localhost:8081 in your browser
⦁ Click on Manage Jenkins. From the list of options, choose Manage Plugins.



⦁ Under the Available tab, select Maven Integration


⦁ Click on Install without restart and the plugin will be installed



⦁ Go to https://maven.apache.org/download.cgi and download the binary zip file


⦁ Unzip and extract the file and copy the path.
```
sudo apt update
$ cd /home/labsuser/Downloads
$ unzip apache-maven-3.6.3-bin.zip
```
# Plugin Installation
dashboard>manage>jenkins>manage plugins>maven integration
⦁ Go to Manage Jenkins from the Jenkins dashboard and select Global Tool Configuration

⦁ Scroll down to the Maven section and click on Add Maven

⦁ You can choose to install automatically by ticking the checkbox and specifying the version, or uncheck the box and enter the local path if you want to configure manually.

⦁ Enter a name for the installation (For Example: my_maven)

⦁ Uncheck the Install automatically checkbox.

⦁ Paste the path to the Maven file in the MAVEN_HOME field (/home/labsuser/Downloads/apache-maven-3.6.

⦁ click Save


⦁ You can now find Maven project as an option under New Item.




## Step 2: Configuring the JDK
⦁ Go to Manage Jenkins from the Jenkins dashboard and select Global Tool Configuration

⦁ Scroll down to the JDK Section and click on Add JDK


⦁ You can choose to install automatically by ticking the checkbox and specifying the version. Uncheck the box if you want to enter the JDK path manually

# References:
1. https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
2. https://maven.apache.org/download.cgi

⦁ Enter the path to the JDK in the JAVA_HOME field (/usr/lib/jvm/java-8-openjdk-amd64/) and click Save
Loading