forked from paulphilip/pythoncode
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsPipeline
More file actions
35 lines (32 loc) · 969 Bytes
/
JenkinsPipeline
File metadata and controls
35 lines (32 loc) · 969 Bytes
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
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 {
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'
}
}
}
}