- Open
pom.xml
in your repository and put this in yourproperties
field
<output.dir>${env.HOME}/Documents</output.dir>
In this example, we are storing the jar in ~/Documents
- In
plugins
field add this
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.ems.springboot.Main</mainClass> <!--Here goes your main class-->
</manifest>
</archive>
<outputDirectory>${output.dir}</outputDirectory>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
- To bundle everything run
mvn clean package -DskipTests
- Open terminal and type the following code to download
jenkins.war
in your home directory.
sudo curl --progress-bar -O -L http://mirrors.jenkins.io/war-stable/latest/jenkins.war
- Run
java -jar jenkins.war --httpPort=8080
. - Browse to http://localhost:8080.
- Follow the instructions to complete the installation.
NOTE: No need to create admin account. In case you forget your password, it is stored in ~/.jekins/secrets/initialAdminPassword
- In your terminal,
cd
to your repository and type
echo "pipeline {
agent any
stages {
stage('Clone') {
steps {
git branch: 'master', url: https://github.com/ashvinsharma/ems-springboot.git
}
}
stage('Build') {
steps {
sh 'mvn --version'
sh 'mvn clean package -DskipTests'
}
}
}
}" > Jenkinsfile
-
In your browser, open Jenkins and click on New Item.
-
Type name for your project and choose pipeline from the list.
-
Select Pipeline tab.
- Definition: Pipeline from SCM
- SCM: Git
- Repository URL:
- Credentials:
- Script Path:
Jenkinsfile
-
Hit
Save
andApply
. -
To check if everything is working click
Build Now
.