-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
70 lines (62 loc) · 2.33 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
pipeline {
agent { label 'small' }
environment {
imagename = 'ghcr.io/pilotdataplatform/pipelinewatch'
commit = sh(returnStdout: true, script: 'git describe --always').trim()
registryCredential = 'pilot-ghcr'
}
stages {
stage('DEV: Git clone') {
when { branch 'develop' }
steps {
git branch: 'develop',
url: 'https://github.com/PilotDataPlatform/pipelinewatch.git',
credentialsId: 'pilot-gh'
}
}
stage('DEV: Run unit tests') {
when { branch 'develop' }
steps {
withCredentials([
string(credentialsId:'VAULT_TOKEN', variable: 'VAULT_TOKEN'),
string(credentialsId:'VAULT_URL', variable: 'VAULT_URL'),
file(credentialsId:'VAULT_CRT', variable: 'VAULT_CRT')
]) {
sh """
pip install --user poetry==1.1.12
${HOME}/.local/bin/poetry config virtualenvs.in-project true
${HOME}/.local/bin/poetry install --no-root --no-interaction
${HOME}/.local/bin/poetry run pytest --verbose
"""
}
}
}
stage('DEV: Build and push image') {
when { branch 'develop' }
steps {
script {
docker.withRegistry('https://ghcr.io', registryCredential) {
customImage = docker.build('$imagename:$commit-CAC')
customImage.push()
}
}
}
}
stage('DEV: Remove image') {
when { branch 'develop' }
steps {
sh 'docker rmi $imagename:$commit-CAC'
}
}
stage('DEV: Deploy') {
when { branch 'develop' }
steps {
build(job: '/VRE-IaC/UpdateAppVersion', parameters: [
[$class: 'StringParameterValue', name: 'TF_TARGET_ENV', value: 'dev'],
[$class: 'StringParameterValue', name: 'TARGET_RELEASE', value: 'pipelinewatch'],
[$class: 'StringParameterValue', name: 'NEW_APP_VERSION', value: "$commit-CAC"]
])
}
}
}
}