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

hai #26

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

hai #26

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
92 changes: 53 additions & 39 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
node{
stage('SCM Checkout'){
git 'https://github.com/damodaranj/my-app.git'
}
stage('Compile-Package'){
@Library('shared') _

def mvnHome = tool name: 'maven3', type: 'maven'
sh "${mvnHome}/bin/mvn clean package"
sh 'mv target/myweb*.war target/newapp.war'
}
stage('SonarQube Analysis') {
def mvnHome = tool name: 'maven3', type: 'maven'
withSonarQubeEnv('sonar') {
sh "${mvnHome}/bin/mvn sonar:sonar"
}
}
stage('Build Docker Imager'){
sh 'docker build -t saidamo/myweb:0.0.2 .'
}
stage('Docker Image Push'){
withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) {
sh "docker login -u saidamo -p ${dockerPassword}"
pipeline
{
agent any
stages
{
stage('checkout')
{
steps
{
SCM("https://github.com/suresh171090/my-app.git")
}
}
stage ('mavenbuilt')
{
steps
{
built()
}
}
stage ('dockerbuild')
{
steps
{
dockerbuilt("span","suresh171090")
}
}
stage ('dockerrun')
{
steps
{
dockerrun("span","suresh171090","task")
}
}
stage ('dockerpush')
{
steps
{
dockerpush("span","suresh171090")
}
}
}
sh 'docker push saidamo/myweb:0.0.2'
}
stage('Nexus Image Push'){
sh "docker login -u admin -p admin123 3.109.144.225:8083"
sh "docker tag saidamo/myweb:0.0.2 3.109.144.225:8083/damo:1.0.0"
sh 'docker push 3.109.144.225:8083/damo:1.0.0'
}

stage('Remove Previous Container'){
try{
sh 'docker rm -f tomcattest'
}catch(error){
// do nothing if there is an exception
}
stage('Docker deployment'){
sh 'docker run -d -p 8090:8080 --name tomcattest saidamo/myweb:0.0.2'
}
}
post {
success {
emailext body: 'A Test EMail',
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
subject: 'success'
}
failure {
emailext body: 'failed',
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
subject: 'failed'
}
}
}
105 changes: 105 additions & 0 deletions jenkinsold
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
node{
stage('SCM Checkout'){
git 'URL'
}
stage('Compile-Package'){

def mvnHome = tool name: 'maven3', type: 'maven'
sh "${mvnHome}/bin/mvn clean package"
sh 'mv target/myweb*.war target/newapp.war'
}
/* stage('SonarQube Analysis') {
def mvnHome = tool name: 'maven3', type: 'maven'
withSonarQubeEnv('sonar') {
sh "${mvnHome}/bin/mvn sonar:sonar"
}
} */
stage('Build Docker Imager'){
sh 'docker build -t suresh171090/myweb:0.0.2 .'
}
stage('Docker Image Push'){
withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) {
sh "docker login -u suresh171090 -p ${dockerPassword}"
}
sh 'docker push suresh171090/myweb:0.0.2'
}
stage('Nexus Image Push'){
sh "docker login -u admin -p admin123 3.109.144.225:8083"
sh "docker tag saidamo/myweb:0.0.2 3.109.144.225:8083/damo:1.0.0"
sh 'docker push 3.109.144.225:8083/damo:1.0.0'
}

stage('Remove Previous Container'){
try{
sh 'docker rm -f tomcattest'
}catch(error){
// do nothing if there is an exception
}
stage('Docker deployment'){
sh 'docker run -d -p 8090:8080 --name tomcattest suresh171090/myweb:0.0.2'
}
}
}



def call(String project, String hubUser) {
sh "docker image build -t ${hubUser}/${project} ."
sh "docker tag ${hubUser}/${project} ${hubUser}/${project}:${ImageTag}"
sh "docker tag ${hubUser}/${project} ${hubUser}/${project}:latest"
withCredentials([usernamePassword(
credentialsId: "docker",
usernameVariable: "USER",
passwordVariable: "PASS"
)]) {
sh "docker login -u '$USER' -p '$PASS'"
}
sh "docker image push ${hubUser}/${project}:${ImageTag}"
sh "docker image push ${hubUser}/${project}:latest"
}




node{
stage('SCM Checkout'){
git 'https://github.com/suresh171090/my-app.git'
}
stage('Compile-Package'){

def mvnHome = tool name: 'maven3', type: 'maven'
sh "${mvnHome}/bin/mvn clean package"
sh 'mv target/myweb*.war target/newapp.war'
}
/* stage('SonarQube Analysis') {
def mvnHome = tool name: 'maven3', type: 'maven'
withSonarQubeEnv('sonar') {
sh "${mvnHome}/bin/mvn sonar:sonar"
}
} */
stage('Build Docker Imager'){
sh 'docker build -t suresh171090/myweb:0.0.2 .'
}
stage('Docker Image Push'){
withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) {
sh "docker login -u suresh171090 -p ${dockerPassword}"
}
sh 'docker push suresh171090/myweb:0.0.2'
}
stage('Nexus Image Push'){
sh "docker login -u admin -p admin123 3.109.144.225:8083"
sh "docker tag saidamo/myweb:0.0.2 3.109.144.225:8083/damo:1.0.0"
sh 'docker push 3.109.144.225:8083/damo:1.0.0'
}

stage('Remove Previous Container'){
try{
sh 'docker rm -f tomcattest'
}catch(error){
// do nothing if there is an exception
}
stage('Docker deployment'){
sh 'docker run -d -p 8090:8080 --name tomcattest suresh171090/myweb:0.0.2'
}
}
}
5 changes: 5 additions & 0 deletions vars/scmcheckout.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def call(String URL)
node{
stage('SCM Checkout'){
git "${URL}"
}