-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
38 lines (35 loc) · 1.13 KB
/
Copy pathJenkinsfile
File metadata and controls
38 lines (35 loc) · 1.13 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 {
GITHUB_REPO = "https://github.com/WilliamDJR/sample-docker-react.git"
DOCKERHUB_USER = "willido"
DOCKERHUB_CREDS = "dockerhub_willido"
}
stages {
stage('CheckOut Code') {
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: "$GITHUB_REPO"]])
}
}
stage('Build Image') {
steps {
sh 'docker build -t $DOCKERHUB_USER/sample-app:jks .'
}
}
stage('Run Tests') {
steps {
echo 'Put your testing command here if you have'
}
}
stage('Publish Image') {
steps {
withCredentials([usernamePassword(credentialsId: "$DOCKERHUB_CREDS", passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
sh '''
docker login -u $USERNAME -p $PASSWORD
docker image push $USERNAME/sample-app:jks
'''
}
}
}
}
}