forked from paulphilip/pythoncode
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsPipeline-2
More file actions
38 lines (35 loc) · 1.18 KB
/
JenkinsPipeline-2
File metadata and controls
38 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pipeline {
agent any
environment {
DOCKERHUB_CREDENTIALS=credentials('docker-key')
}
parameters {
string(name: 'dockerUser', defaultValue: 'None', description: 'Enter Docker user name ')
}
stages {
stage('Clone') {
steps {
git branch: 'main', url: 'https://github.com/rajpalsinghsaini/pythoncode.git'
}
}
stage('Build') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker-key', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh "docker login --username ${USERNAME} -p ${PASSWORD}"
}
//sh 'docker ps'
//sh "echo $DOCKERHUB_CREDENTIALS_PSW | docker login --username ${dockerUser} --password-stdin"
}
}
stage('Test') {
steps {
sh 'docker build /var/lib/jenkins/workspace/${JOB_NAME} -t ${dockerUser}/pythoncode'
}
}
stage('Deploy') {
steps {
sh 'docker run -tid -p 81:80 ${dockerUser}/pythoncode:latest'
}
}
}
}