This commit is contained in:
Sieciech 2021-07-27 14:05:54 +02:00
parent 1d9f5bbc50
commit 797f83b777
3 changed files with 72 additions and 5 deletions

69
Jenkinsfile vendored
View File

@ -1,5 +1,10 @@
pipeline { pipeline {
agent any agent any
environment {
DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} DatabaseUrl').trim()
}
stages { stages {
stage('Pull') { stage('Pull') {
steps { steps {
@ -7,11 +12,34 @@ pipeline {
} }
} }
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') { stage('Install') {
parallel { parallel {
stage('Frontend') { stage('Frontend') {
steps { steps {
dir(path: 'frontend') { dir(path: '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' sh 'npm ci'
} }
@ -21,7 +49,7 @@ pipeline {
stage('Backend') { stage('Backend') {
steps { steps {
dir(path: 'backend') { dir(path: 'backend') {
sh 'composer install' sh 'php8.0 /bin/composer install'
} }
} }
@ -44,6 +72,8 @@ pipeline {
stage('Backend') { stage('Backend') {
steps { steps {
dir(path: 'backend') { dir(path: '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=${DatabaseUrl}/g" .env.dev'
sh 'composer dump-env dev' sh 'composer dump-env dev'
} }
@ -58,7 +88,7 @@ pipeline {
stage('Frontend') { stage('Frontend') {
steps { steps {
dir(path: 'frontend') { dir(path: 'frontend') {
sh 'echo skip' sh 'ng lint'
} }
} }
@ -67,7 +97,30 @@ pipeline {
stage('Backend') { stage('Backend') {
steps { steps {
dir(path: 'backend') { dir(path: 'backend') {
sh 'php vendor/bin/phpunit' sh 'php8.0 vendor/bin/phpunit'
}
}
}
}
}
stage('Build') {
parallel {
stage('Frontend') {
steps {
dir(path: 'frontend') {
sh 'ng b -c production'
}
}
}
stage('Backend') {
steps {
dir(path: 'backend') {
sh 'echo skip'
} }
} }
@ -77,6 +130,16 @@ pipeline {
} }
stage('Deploy') { stage('Deploy') {
when {
anyOf {
branch 'prod'
branch 'staging'
branch 'beta'
branch 'dev'
}
}
parallel { parallel {
stage('Frontend') { stage('Frontend') {
steps { steps {

View File

@ -1,3 +1,5 @@
export const environment = { export const environment = {
production: true production: true,
buildId: -1001,
buildTime: -1002,
}; };

View File

@ -3,7 +3,9 @@
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
export const environment = { export const environment = {
production: false production: false,
buildId: -1001,
buildTime: -1002,
}; };
/* /*