-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
54 lines (54 loc) · 1.19 KB
/
Jenkinsfile
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
pipeline {
agent any
tools { nodejs "node" }
environment {
GH_TOKEN = credentials('jenkins-pat')
}
stages {
stage('Clone repository') {
when {
branch 'master'
}
steps {
cleanWs()
checkout scm
}
}
stage('Release with semantic-release') {
when {
branch 'master'
}
steps {
sh '''
npm ci
npx semantic-release
'''
}
}
stage('Build Image') {
when {
branch 'master'
}
steps {
sh 'docker build --no-cache -t quay.io/pwncorp/producer:$(npm pkg get version | xargs) -t quay.io/pwncorp/producer:latest -f Dockerfile .'
}
}
stage('Push Image') {
when {
branch 'master'
}
steps {
withCredentials([usernamePassword(credentialsId: 'dockerHub', passwordVariable: 'DOCKERHUB_PASSWORD', usernameVariable: 'DOCKERHUB_USERNAME')]) {
sh 'docker login quay.io -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD'
sh 'docker image push --all-tags quay.io/pwncorp/producer'
}
}
}
}
post {
always {
sh 'docker logout'
sh 'docker system prune -a -f'
}
}
}