2020-01-17 12:07:01 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
2024-02-22 08:25:38 +00:00
|
|
|
def BRANCH_ENV = [
|
|
|
|
test: 'test',
|
|
|
|
master: 'production'
|
|
|
|
]
|
2024-07-04 09:08:26 +00:00
|
|
|
def remote = [:]
|
2024-07-09 14:55:20 +00:00
|
|
|
def changesFile
|
2024-02-22 08:25:38 +00:00
|
|
|
|
|
|
|
node {
|
|
|
|
stage('Setup') {
|
|
|
|
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
|
|
|
|
|
|
|
|
echo "NODE_NAME: ${env.NODE_NAME}"
|
|
|
|
echo "WORKSPACE: ${env.WORKSPACE}"
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
pipeline {
|
2020-01-21 08:01:05 +00:00
|
|
|
agent any
|
2020-01-17 12:07:01 +00:00
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'hedera-web'
|
|
|
|
}
|
|
|
|
stages {
|
2022-10-10 11:22:17 +00:00
|
|
|
stage('Debuild') {
|
2020-01-17 12:07:01 +00:00
|
|
|
when {
|
2022-05-05 09:19:29 +00:00
|
|
|
anyOf {
|
|
|
|
branch 'master'
|
|
|
|
branch 'test'
|
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
2024-07-05 11:18:18 +00:00
|
|
|
image 'registry.verdnatura.es/debuild:2.23.4-vn6'
|
2020-01-21 08:00:03 +00:00
|
|
|
registryUrl 'https://registry.verdnatura.es/'
|
|
|
|
registryCredentialsId 'docker-registry'
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
steps {
|
2024-07-04 17:00:35 +00:00
|
|
|
sh 'debuild -us -uc -b'
|
2024-07-09 15:31:24 +00:00
|
|
|
//sh 'mkdir -p output'
|
|
|
|
//sh 'mv ../*.deb ../*.build ../*.changes ../*.buildinfo output'
|
2024-07-05 08:04:10 +00:00
|
|
|
|
2024-07-09 15:31:24 +00:00
|
|
|
script {
|
|
|
|
def files = findFiles(glob: '../*.changes')
|
|
|
|
files.each { file -> changesFile = file.name }
|
|
|
|
}
|
|
|
|
|
|
|
|
withCredentials([sshUserPrivateKey(
|
|
|
|
credentialsId: 'jenkins-agent',
|
|
|
|
keyFileVariable: 'keyFile'
|
|
|
|
)]) {
|
|
|
|
configFileProvider([
|
|
|
|
configFile(fileId: "dput.cf",
|
|
|
|
variable: 'DPUT_CONFIG')
|
|
|
|
]) {
|
|
|
|
echo changesFile
|
|
|
|
echo 'dput --config $DPUT_CONFIG verdnatura'
|
|
|
|
sleep 86400
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//stash includes: 'output/*', name: 'debuildOutput'
|
2024-07-04 09:08:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Reprepro') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
branch 'master'
|
|
|
|
branch 'test'
|
|
|
|
}
|
|
|
|
}
|
2024-07-09 08:45:22 +00:00
|
|
|
environment {
|
2024-07-09 14:55:20 +00:00
|
|
|
REPREPRO_BASE_DIR = '/var/lib/reprepro/repo'
|
2024-07-09 08:45:22 +00:00
|
|
|
}
|
2024-07-04 09:08:26 +00:00
|
|
|
steps {
|
2024-07-05 09:08:44 +00:00
|
|
|
unstash 'debuildOutput'
|
2024-07-05 09:10:10 +00:00
|
|
|
script {
|
2024-07-09 14:55:20 +00:00
|
|
|
def files = findFiles(glob: 'output/*.changes')
|
|
|
|
files.each { file -> changesFile = file.name }
|
2024-07-05 11:01:49 +00:00
|
|
|
}
|
2024-07-05 08:29:35 +00:00
|
|
|
|
2024-07-05 11:07:53 +00:00
|
|
|
withCredentials([sshUserPrivateKey(
|
|
|
|
credentialsId: 'jenkins-agent',
|
|
|
|
usernameVariable: 'user',
|
2024-07-05 11:41:43 +00:00
|
|
|
keyFileVariable: 'keyFile'
|
2024-07-05 11:07:53 +00:00
|
|
|
)]) {
|
|
|
|
script {
|
2024-07-05 11:02:48 +00:00
|
|
|
remote.user = user
|
2024-07-05 11:43:41 +00:00
|
|
|
remote.identityFile = keyFile
|
2024-07-05 11:02:48 +00:00
|
|
|
remote.name = 'reprepro'
|
|
|
|
remote.host = 'reprepro.reprepro'
|
|
|
|
remote.allowAnyHosts = true
|
|
|
|
}
|
2024-07-05 11:07:53 +00:00
|
|
|
sshPut([
|
|
|
|
remote: remote,
|
2024-07-09 14:55:20 +00:00
|
|
|
from: "output/$changesFile",
|
|
|
|
into: "$REPREPRO_BASE_DIR/incoming"
|
2024-07-05 11:07:53 +00:00
|
|
|
])
|
2024-07-05 11:55:23 +00:00
|
|
|
sshCommand([
|
2024-07-05 11:07:53 +00:00
|
|
|
remote: remote,
|
2024-07-09 14:55:20 +00:00
|
|
|
command: "reprepro processincoming default $changesFile"
|
2024-07-05 11:07:53 +00:00
|
|
|
])
|
2024-07-05 08:29:35 +00:00
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-09 10:04:23 +00:00
|
|
|
stage('Deploy') {
|
2020-01-21 08:00:03 +00:00
|
|
|
when {
|
2022-05-05 09:19:29 +00:00
|
|
|
anyOf {
|
|
|
|
branch 'master'
|
|
|
|
branch 'test'
|
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
|
|
|
environment {
|
|
|
|
CREDS = credentials('docker-registry')
|
2024-07-09 10:16:31 +00:00
|
|
|
IMAGE = "$REGISTRY/verdnatura/hedera-web"
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
|
|
|
steps {
|
2024-02-22 08:25:38 +00:00
|
|
|
script {
|
|
|
|
def packageJson = readJSON file: 'package.json'
|
2024-07-09 10:04:23 +00:00
|
|
|
env.VERSION = "${packageJson.version}"
|
|
|
|
env.TAG = "${packageJson.version}-build${env.BUILD_ID}"
|
2024-02-22 08:25:38 +00:00
|
|
|
}
|
2024-07-09 10:04:23 +00:00
|
|
|
|
2020-01-21 08:56:35 +00:00
|
|
|
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
2024-07-09 14:55:20 +00:00
|
|
|
sh 'docker tag $IMAGE:$TAG $IMAGE:latest'
|
2024-07-09 10:16:31 +00:00
|
|
|
|
|
|
|
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
2024-07-09 14:55:20 +00:00
|
|
|
sh 'docker push $IMAGE:$TAG'
|
|
|
|
sh 'docker push $IMAGE:latest'
|
2024-07-09 10:04:23 +00:00
|
|
|
|
2024-05-27 08:11:03 +00:00
|
|
|
withKubeConfig([
|
|
|
|
serverUrl: "$KUBERNETES_API",
|
|
|
|
credentialsId: 'kubernetes',
|
|
|
|
namespace: 'salix'
|
|
|
|
]) {
|
2024-07-09 10:16:31 +00:00
|
|
|
sh 'kubectl set image deployment/hedera-web-$BRANCH_NAME hedera-web-$BRANCH_NAME=$IMAGE:$TAG'
|
|
|
|
sh 'kubectl set image deployment/hedera-web-cron-$BRANCH_NAME hedera-web-cron-$BRANCH_NAME=$IMAGE:$TAG'
|
2024-05-27 08:11:03 +00:00
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
|
|
|
post {
|
2022-05-05 09:05:05 +00:00
|
|
|
unsuccessful {
|
2024-02-22 08:25:38 +00:00
|
|
|
setEnv()
|
2021-04-29 22:20:36 +00:00
|
|
|
sendEmail()
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-05 09:05:05 +00:00
|
|
|
}
|