2021-07-27 20:35:53 +00:00
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
|
|
|
|
environment {
|
2021-08-05 08:13:24 +00:00
|
|
|
DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh dev DatabaseUrl').trim()
|
|
|
|
ProjectPath = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh dev ProjectPath').trim()
|
2021-07-27 20:35:53 +00:00
|
|
|
DatabaseUrlTesting = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh master DatabaseUrl').trim()
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Pull') {
|
|
|
|
steps {
|
|
|
|
git(url: 'http://git.fufle.net/Community/CureNet.git', branch: '${BRANCH_NAME}', credentialsId: '799188a2-c281-4e4c-b78f-c82132ea792b', poll: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Approve') {
|
|
|
|
steps {
|
|
|
|
echo "http://git.fufle.net/Community/CureNet/commit/${env.GIT_COMMIT}"
|
|
|
|
script {
|
|
|
|
if (env.BRANCH_NAME == "prod") {
|
|
|
|
echo "http://git.fufle.net/Community/CureNet/compare/prod...staging"
|
|
|
|
input(message: 'Deploy to production?', id: 'A', ok: 'Yes', submitter: 'deploy', submitterParameter: 'a')
|
|
|
|
}
|
|
|
|
if (env.BRANCH_NAME == "staging") {
|
|
|
|
echo "http://git.fufle.net/Community/CureNet/compare/staging...beta"
|
|
|
|
input(message: 'Deploy to staging instance?', id: 'A', ok: 'Yes', submitter: 'deploy', submitterParameter: 'a')
|
|
|
|
}
|
|
|
|
if (env.BRANCH_NAME == "beta") {
|
|
|
|
echo "http://git.fufle.net/Community/CureNet/compare/beta...dev"
|
|
|
|
input(message: 'Deploy to beta instance?', id: 'A', ok: 'Yes', submitter: 'deploy', submitterParameter: 'a')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Install') {
|
|
|
|
parallel {
|
|
|
|
stage('Frontend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/frontend') {
|
|
|
|
sh 'sed -i "s/-1001/${BUILD_ID}/g" src/environments/*.ts'
|
|
|
|
sh 'Timestamp=`php8.0 -r "echo time();"` && sed -i "s/-1002/${Timestamp}/g" src/environments/*.ts'
|
|
|
|
sh 'npm ci'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Backend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/backend') {
|
2021-07-28 09:03:07 +00:00
|
|
|
sh 'php8.0 /usr/local/bin/composer install'
|
2021-07-27 20:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Configure for tests') {
|
|
|
|
parallel {
|
|
|
|
stage('Frontend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/frontend') {
|
|
|
|
sh 'echo skip'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Backend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/backend') {
|
|
|
|
sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env'
|
|
|
|
sh '''sed -i 's/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrlTesting}/g' .env.test'''
|
2021-07-28 13:43:36 +00:00
|
|
|
sh 'php8.0 /usr/local/bin/composer dump-env test'
|
2021-07-27 20:35:53 +00:00
|
|
|
sh 'php8.0 bin/console doctrine:schema:update --force';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Test') {
|
|
|
|
parallel {
|
|
|
|
stage('Frontend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/frontend') {
|
|
|
|
sh 'ng lint'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Backend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/backend') {
|
|
|
|
sh 'php8.0 vendor/bin/phpunit'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Configure') {
|
|
|
|
parallel {
|
|
|
|
stage('Frontend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/frontend') {
|
|
|
|
sh 'echo skip'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Backend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/backend') {
|
2021-07-28 15:05:01 +00:00
|
|
|
sh '''APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i 's/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g' .env'''
|
|
|
|
sh '''sed -i 's/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g' .env.dev'''
|
2021-07-28 13:43:36 +00:00
|
|
|
sh 'php8.0 /usr/local/bin/composer dump-env dev'
|
2021-07-27 20:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build') {
|
|
|
|
parallel {
|
|
|
|
stage('Frontend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/frontend') {
|
|
|
|
sh 'ng b -c production'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Backend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/backend') {
|
|
|
|
sh 'echo skip'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Deploy') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
branch 'master'
|
|
|
|
branch 'staging'
|
|
|
|
branch 'beta'
|
|
|
|
branch 'dev'
|
2021-08-05 07:20:32 +00:00
|
|
|
branch '29-profile-page'
|
2021-07-27 20:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
parallel {
|
|
|
|
stage('Frontend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/frontend') {
|
|
|
|
sh 'ssh web@fufle.net touch ${ProjectPath}/frontend/REMOVEME'
|
|
|
|
sh 'ssh web@fufle.net rm -rf ${ProjectPath}/frontend/*'
|
|
|
|
sh 'scp -r dist/* web@fufle.net:${ProjectPath}/frontend/'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Backend') {
|
|
|
|
steps {
|
|
|
|
dir(path: 'src/backend') {
|
|
|
|
sh 'ssh web@fufle.net touch ${ProjectPath}/backend/REMOVEME'
|
|
|
|
sh 'ssh web@fufle.net rm -rf ${ProjectPath}/backend/*'
|
|
|
|
sh 'scp -r ./* web@fufle.net:${ProjectPath}/backend/'
|
2021-08-05 07:20:32 +00:00
|
|
|
sh 'scp -r ./.env web@fufle.net:${ProjectPath}/backend/.env'
|
2021-07-27 20:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|