-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
93 lines (85 loc) · 3.44 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
81
82
83
84
85
86
87
88
89
90
91
92
93
pipeline {
agent { label 'small' }
environment {
imagename = "ghcr.io/pilotdataplatform/metadata-event-handler"
commit = sh(returnStdout: true, script: 'git describe --always').trim()
registryCredential = 'pilot-ghcr'
dockerImage = ''
}
stages {
stage('DEV Git clone') {
when { branch 'develop' }
steps {
git branch: 'develop',
url: 'https://github.com/PilotDataPlatform/metadata-event-handler.git',
credentialsId: 'pilot-gh'
}
}
// stage('DEV Run unit tests') {
// when { branch 'develop' }
// steps {
// withCredentials([
// usernamePassword(credentialsId: 'indoc-ssh', usernameVariable: 'SUDO_USERNAME', passwordVariable: 'SUDO_PASSWORD'),
// string(credentialsId:'VAULT_TOKEN', variable: 'VAULT_TOKEN'),
// string(credentialsId:'VAULT_URL', variable: 'VAULT_URL'),
// file(credentialsId:'VAULT_CRT', variable: 'VAULT_CRT')
// ]) {
// sh """
// export OPSDB_UTILILY_USERNAME=postgres
// export OPSDB_UTILILY_PASSWORD=postgres
// export OPSDB_UTILILY_HOST=db
// export OPSDB_UTILILY_PORT=5432
// export OPSDB_UTILILY_NAME=metadata-event-handler
// [ ! -f ${env.WORKSPACE}/.env ] && touch ${env.WORKSPACE}/.env
// [ -d ${env.WORKSPACE}/local_config/pgadmin/sessions ] && sudo chmod 777 -R -f ${env.WORKSPACE}/local_config/pgadmin/sessions
// sudo chmod 777 -R -f ${env.WORKSPACE}/local_config/pgadmin/sessions
// docker build -t web .
// docker-compose -f docker-compose.yaml down -v
// docker-compose up -d
// sleep 10s
// docker-compose exec -T web /bin/bash
// pwd
// hostname
// docker-compose exec -T web pip install --user poetry==1.1.12
// docker-compose exec -T web poetry config virtualenvs.in-project false
// docker-compose exec -T web poetry install --no-root --no-interaction
// docker-compose exec -T web poetry run pytest --verbose -c tests/pytest.ini
// docker-compose -f docker-compose.yaml down -v
// """
// }
// }
// }
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: 'metadata-event-handler' ],
[$class: 'StringParameterValue', name: 'NEW_APP_VERSION', value: "$commit-CAC" ]
])
}
}
}
post {
failure {
slackSend color: '#FF0000', message: "Build Failed! - ${env.JOB_NAME} $commit (<${env.BUILD_URL}|Open>)", channel: 'jenkins-dev-staging-monitor'
}
}
}