-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
47 lines (44 loc) · 1.37 KB
/
Jenkinsfile
File metadata and controls
47 lines (44 loc) · 1.37 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
39
40
41
42
43
44
45
46
47
#!/usr/bin/env groovy
pipeline {
agent any
environment {
registry = "registry.hyneo.ru/site-backend"
registryCredential = "nexusadmin"
dockerImage = ''
}
stages {
stage('Build') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
}
}
}
stage('Push registry nexus'){
steps{
script{
docker.withRegistry('https://registry.hyneo.ru', registryCredential ) {
dockerImage.push()
dockerImage.push('latest')
}
}
}
}
stage ('Deploy') {
steps{
sshagent(credentials : ['microhost']) {
sh '''
[ -d ~/.ssh ] || mkdir ~/.ssh && chmod 0700 ~/.ssh
ssh-keyscan -t rsa,dsa -p 22 185.200.243.214 >> ~/.ssh/known_hosts
ssh -p 11 root@185.200.243.214 'cd ./site && docker compose pull proxmox_api && docker compose restart proxmox_api'
'''
}
}
}
stage('Dangling Images') {
steps {
sh 'docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi'
}
}
}
}