Skip to content

Commit bfd6b12

Browse files
Create JenkinsPipeline-2
1 parent 973c751 commit bfd6b12

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

JenkinsPipeline-2

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
pipeline {
2+
agent any
3+
4+
environment {
5+
DOCKERHUB_CREDENTIALS=credentials('docker-key')
6+
}
7+
parameters {
8+
string(name: 'dockerUser', defaultValue: 'None', description: 'Enter Docker user name ')
9+
}
10+
stages {
11+
stage('Clone') {
12+
steps {
13+
git branch: 'main', url: 'https://github.com/rajpalsinghsaini/pythoncode.git'
14+
}
15+
}
16+
stage('Build') {
17+
steps {
18+
withCredentials([usernamePassword(credentialsId: 'docker-key', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
19+
sh "docker login --username ${USERNAME} -p ${PASSWORD}"
20+
}
21+
//sh 'docker ps'
22+
//sh "echo $DOCKERHUB_CREDENTIALS_PSW | docker login --username ${dockerUser} --password-stdin"
23+
24+
}
25+
}
26+
stage('Test') {
27+
steps {
28+
sh 'docker build /var/lib/jenkins/workspace/${JOB_NAME} -t ${dockerUser}/pythoncode'
29+
30+
}
31+
}
32+
stage('Deploy') {
33+
steps {
34+
sh 'docker run -tid -p 81:80 ${dockerUser}/pythoncode:latest'
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)