Skip to content

Commit 76d1a7f

Browse files
Update Jenkinsfile
1 parent d0cc6aa commit 76d1a7f

1 file changed

Lines changed: 38 additions & 26 deletions

File tree

Jenkinsfile

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1+
#!groovy
12
pipeline {
2-
agent any
3-
stages {
4-
stage('Checkout') {
5-
steps {
6-
echo 'Checkout completed'
7-
}
8-
}
9-
stage('Static-test') {
10-
steps {
11-
echo 'Running static tests on code'
12-
}
13-
}
14-
stage('Build') {
15-
when {
16-
branch "master"
3+
environment {
4+
registry = 'nithishnithi/tomcat'
5+
registryCredentials = 'Docker_credential'
6+
}
7+
agent {label'docker'}
8+
stages{
9+
stage('git-checkout') {
10+
steps {
11+
git branch: 'main', url: 'https://github.com/Nithishkumar0064/java-example.git'
12+
}
13+
}
14+
stage('Build docker image'){
15+
steps {
16+
script {
17+
image = docker.build("${registry}:$BUILD_NUMBER")
18+
}
19+
}
20+
}
21+
stage('Push image to Hub'){
22+
steps {
23+
sh 'echo Registry-push'
24+
script {
25+
docker.withRegistry('', registryCredentials) {
26+
image.push()
27+
image.push('latest')
28+
}
29+
}
30+
}
31+
}
32+
stage('Deploy ') {
33+
steps {
34+
sh 'docker run -itd --name cont-${BUILD_ID} -p 8080:8080 ${registry} :${BUILD_ID}
35+
}
36+
37+
}
38+
1739
}
18-
steps {
19-
sh 'echo "Building the code"'
20-
}
21-
}
22-
stage('Deploy') {
23-
steps {
24-
echo 'Deploying into environment'
25-
}
26-
}
27-
}
28-
}
40+
}

0 commit comments

Comments
 (0)