-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
128 lines (127 loc) · 4.9 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
def tag = ["master":"latest", "develop":"develop" ]
def scmVars
pipeline {
environment {
DOCKER_NETWORK = ''
}
options {
skipDefaultCheckout()
buildDiscarder(logRotator(numToKeepStr: '20'))
timestamps()
}
agent any
stages {
stage ('Stop same job builds') {
agent { label 'master' }
steps {
script {
scmVars = checkout scm
// need this for develop->master PR cases
// CHANGE_BRANCH is not defined if this is a branch build
try {
scmVars.CHANGE_BRANCH_LOCAL = scmVars.CHANGE_BRANCH
}
catch(MissingPropertyException e) { }
if (scmVars.GIT_LOCAL_BRANCH != "develop" && scmVars.CHANGE_BRANCH_LOCAL != "develop") {
def builds = load ".jenkinsci/cancel-builds-same-job.groovy"
builds.cancelSameJobBuilds()
}
}
}
post {
cleanup {
cleanWs()
}
}
}
// stage('Tests (unit, e2e)') {
// agent { label 'd3-build-agent' }
// steps {
// script {
// scmVars = checkout scm
// DOCKER_NETWORK = "${scmVars.CHANGE_ID}-${scmVars.GIT_COMMIT}-${BUILD_NUMBER}"
// writeFile file: ".env", text: "SUBNET=${DOCKER_NETWORK}"
// sh(returnStdout: true, script: "docker-compose -f docker/docker-compose.yaml pull")
// sh(returnStdout: true, script: "docker-compose -f docker/docker-compose.yaml up --build -d")
// sh(returnStdout: true, script: "docker exec d3-back-office-${DOCKER_NETWORK} /app/docker/back-office/wait-for-up.sh")
// iC = docker.image('cypress/base:10')
// iC.inside("--network='d3-${DOCKER_NETWORK}' --shm-size 4096m --ipc=host") {
// sh(script: "yarn global add cypress")
// var = sh(returnStatus:true, script: "yarn test:unit")
// if (var != 0) {
// echo '[FAILURE] Unit tests failed'
// currentBuild.result = 'FAILURE';
// return var
// }
// var = sh(returnStatus:true, script: "CYPRESS_baseUrl=http://d3-back-office:8080 CYPRESS_IROHA=http://grpcwebproxy:8080 cypress run")
// if (var != 0) {
// echo '[FAILURE] E2E tests failed'
// currentBuild.result = 'FAILURE';
// return var
// }
// }
// }
// }
// post {
// success {
// script {
// if (env.GIT_LOCAL_BRANCH in ["develop"] || env.CHANGE_BRANCH_LOCAL == 'develop') {
// def branch = env.CHANGE_BRANCH_LOCAL == 'develop' ? env.CHANGE_BRANCH_LOCAL : env.GIT_LOCAL_BRANCH
// sshagent(['jenkins-back-office']) {
// sh "ssh-agent"
// sh """
// rsync \
// -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
// -rzcv --delete \
// dist/* \
// [email protected]:/var/www/dev/
// """
// }
// }
// }
// }
// always {
// script {
// withCredentials([usernamePassword(credentialsId: 'jenkins_nexus_creds', passwordVariable: 'NEXUS_PASS', usernameVariable: 'NEXUS_USER')]) {
// sh(script: "find \$(pwd)/tests/e2e/videos/*.mp4 -type f -exec curl -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file {} https://nexus.iroha.tech/repository/back-office/crashes/${DOCKER_NETWORK}/ \\;", returnStdout: true)
// echo "You can find all videos here: https://nexus.iroha.tech/service/rest/repository/browse/back-office/crashes/${DOCKER_NETWORK}/"
// }
// }
// }
// cleanup {
// sh "mkdir build-logs"
// sh """#!/bin/bash
// while read -r LINE; do \
// docker logs \$(echo \$LINE | cut -d ' ' -f1) | gzip -6 > build-logs/\$(echo \$LINE | cut -d ' ' -f2).log.gz; \
// done < <(docker ps --filter "network=d3-${DOCKER_NETWORK}" --format "{{.ID}} {{.Names}}")
// """
// archiveArtifacts artifacts: 'build-logs/*.log.gz'
// sh "docker-compose -f docker/docker-compose.yaml down"
// cleanWs()
// }
// }
// }
stage('Build') {
when {
beforeAgent true
expression { return (scmVars.GIT_BRANCH in tag || scmVars.TAG_NAME) }
}
agent { label 'd3-build-agent' }
steps {
script {
scmVars = checkout scm
docker_tag = scmVars.TAG_NAME ? scmVars.TAG_NAME : tag[scmVars.GIT_BRANCH]
def iC = docker.build("nexus.iroha.tech:19002/d3-deploy/back-office:${tag[scmVars.GIT_BRANCH]}")
docker.withRegistry('https://nexus.iroha.tech:19002', 'nexus-d3-docker') {
iC.push()
}
}
}
post {
cleanup {
cleanWs()
}
}
}
}
}