-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
80 lines (73 loc) · 2.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!groovy
pipeline {
agent {
label 'pipeline'
}
tools {
jdk 'java-17-lts'
maven 'maven'
nodejs 'nodejs14-lts'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build Frontend') {
steps {
dir('jsapp') {
withNPM(npmrcConfig: 'a609eeee-735e-43fa-b15e-a9e30841616c') {
sh 'npm install'
sh 'npm run build'
}
}
}
}
stage('Build API') {
steps {
withMaven(maven: 'maven') {
sh "mvn clean package -U -Dmaven.test.skip=true"
}
}
}
stage('Generate Docker Image') {
steps {
script {
def imageVersion = ''
def imageTag = ''
if (env.TAG_NAME) {
imageVersion = env.TAG_NAME
} else {
def adjustedBranch = env.BRANCH_NAME.replace('/', '-')
imageVersion = "${adjustedBranch}-${env.BUILD_NUMBER}"
if (env.BRANCH_NAME == 'develop') {
imageTag = 'latest'
} else {
imageTag = "${adjustedBranch}-latest"
}
}
docker.withRegistry('https://registry.senado.leg.br', 'docker-registry-deployer') {
def image = docker.build("leg/editor-emendas:${imageVersion}",
'--build-arg uid=2000 --build-arg gid=2000 .')
image.push()
if (imageTag) {
image.push(imageTag)
}
}
}
}
}
stage('Deploy') {
when {
branch 'develop'
}
steps {
build job: 'stack-leg-editor-emendas',
parameters: [
string(name: 'ambiente', value: 'desenvolvimento')
]
}
}
}
}