Create pipeline #20

Merged
Sieciech merged 12 commits from 4-pipeline into dev 2021-07-27 20:35:55 +00:00
3 changed files with 72 additions and 5 deletions
Showing only changes of commit 797f83b777 - Show all commits

69
Jenkinsfile vendored
View File

@ -1,5 +1,10 @@
pipeline {
agent any
environment {
DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} DatabaseUrl').trim()
}
stages {
stage('Pull') {
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') {
parallel {
stage('Frontend') {
steps {
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'
}
@ -21,7 +49,7 @@ pipeline {
stage('Backend') {
steps {
dir(path: 'backend') {
sh 'composer install'
sh 'php8.0 /bin/composer install'
}
}
@ -44,6 +72,8 @@ pipeline {
stage('Backend') {
steps {
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'
}
@ -58,7 +88,7 @@ pipeline {
stage('Frontend') {
steps {
dir(path: 'frontend') {
sh 'echo skip'
sh 'ng lint'
}
}
@ -67,7 +97,30 @@ pipeline {
stage('Backend') {
steps {
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') {
when {
anyOf {
branch 'prod'
branch 'staging'
branch 'beta'
branch 'dev'
}
}
parallel {
stage('Frontend') {
steps {

View File

@ -1,3 +1,5 @@
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`.
export const environment = {
production: false
production: false,
buildId: -1001,
buildTime: -1002,
};
/*