Skip to content

Commit

Permalink
Update Jenkinsfile-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
vcjain authored Oct 21, 2023
1 parent 2e7b27a commit 54d5712
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions Jenkinsfile-docker
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
pipeline{
agent {
docker {
image 'ubuntu'
pipeline {
agent {
docker {
image 'maven:3.8.1-adoptopenjdk-11'
label 'ssh'
args '-v /var/run/docker.sock:/var/run/docker.sock -u root'
}
}
}
stages{
stage('Preparing Container'){
stage('checkout'){
steps{
echo 'Hello from docker container'
sh 'whoami'
sh 'apt-get update -y'
sh 'apt-get install openjdk-17-jdk -y'
sh 'java -version'
sh 'apt-get install wget -y'
sh 'wget https://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz'
sh 'tar -xvf apache-maven-3.6.3-bin.tar.gz'
sh 'mv apache-maven-3.6.3 /opt/'
sh 'export PATH=/opt/apache-maven-3.6.3/bin:${PATH}'
sh 'ls /opt'
sh 'ls /opt/apache-maven-3.6.3'
sh '/opt/apache-maven-3.6.3/bin/mvn -version'
}
checkout poll: false, scm: scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vcjain/docker-agent-demo.git']])
}
}
stage('Checkout'){
stage('Build'){
steps{
checkout poll: false, scm: scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vcjain/docker-agent-demo.git']])
echo 'Building Maven project'
sh 'mvn install'
archiveArtifacts artifacts: 'target/calculator-0.0.1-SNAPSHOT.jar', followSymlinks: false
}
}
stage('Build'){
stage('Test'){
steps{
echo "Build Stage is in progress "
sh '/opt/apache-maven-3.6.3/bin/mvn compile'
echo 'Building Maven project'
sh 'mvn test'
junit '**/target/surefire-reports/*.xml'
jacoco classPattern: '**/target/classes', exclusionPattern: '**/*Test*.class', execPattern: '**/target/jacoco.exec', inclusionPattern: '**/*.class', sourceExclusionPattern: 'generated/**/*.java', sourceInclusionPattern: '**/*.java'
}
}
}

}
}

0 comments on commit 54d5712

Please sign in to comment.