Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
9fb21dcf
There was an error fetching the commit references. Please try again later.
Commit
9fb21dcf
authored
6 years ago
by
Daniel Gerhardt
Browse files
Options
Downloads
Plain Diff
Merge branch 'ci' into 2.x
parents
732ccd6d
c809ac3d
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+84
-45
84 additions, 45 deletions
.gitlab-ci.yml
with
84 additions
and
45 deletions
.gitlab-ci.yml
+
84
−
45
View file @
9fb21dcf
variables
:
MIRROR_REPO
:
git@github.com:thm-projects/arsnova-backend.gi
t
WAR_FILE
:
target
/arsnova-backend-*.war
OUTPUT_DIR
:
targe
t
WAR_FILE
:
$OUTPUT_DIR
/arsnova-backend-*.war
stages
:
-
analysis
-
test
-
build
-
post-build
-
deploy
-
synchronization
cache
:
.maven_cache
:
&maven_
cache
paths
:
-
.m2/
sync_mirror
:
stage
:
synchronization
when
:
always
except
:
-
production
-
staging
tags
:
-
git
allow_failure
:
true
script
:
-
mkdir ~/.ssh && echo "$GITHUB_HOST_KEY" > ~/.ssh/known_hosts
-
eval $(ssh-agent -s) && ssh-add <(echo "$GITHUB_DEPLOY_KEY")
-
git clone --bare "$CI_REPOSITORY_URL" mirror.git
-
cd mirror.git
-
git update-ref -d refs/tags/production
-
git update-ref -d refs/tags/staging
-
git push --mirror "$MIRROR_REPO"
sonar
:
stage
:
analysis
only
:
-
master
checkstyle
:
stage
:
build
tags
:
-
maven
cache
:
*maven_cache
allow_failure
:
true
script
:
-
mvn
sonar:sonar
-
mvn
-B checkstyle:check
c
hecksty
le
:
stage
:
analysis
c
ompi
le
:
stage
:
build
tags
:
-
maven
artifacts
:
paths
:
-
$OUTPUT_DIR
cache
:
*maven_cache
script
:
-
mvn
checkstyle:checksty
le
-
mvn
-B test-compi
le
test
:
stage
:
test
unit_
test
:
stage
:
post-build
tags
:
-
maven
dependencies
:
-
compile
artifacts
:
paths
:
-
$OUTPUT_DIR
cache
:
*maven_cache
script
:
-
mvn test
-
mvn
-B surefire:
test
package
:
stage
:
build
stage
:
post-
build
tags
:
-
maven
dependencies
:
-
compile
artifacts
:
name
:
package
paths
:
-
$WAR_FILE
cache
:
*maven_cache
script
:
-
mvn
package -DskipTests
-
mvn
-B war:war
tomcat_production
:
.deploy
:
&deploy
stage
:
deploy
only
:
-
production
tags
:
-
curl
-
python
when
:
manual
variables
:
DEPLOY_CONTEXT
:
api
GIT_STRATEGY
:
none
dependencies
:
-
package
script
:
-
curl --fail --upload-file $WAR_FILE "https://$PROD_TOMCAT_USER:$PROD_TOMCAT_PASSWORD@$PROD_TOMCAT_HOST/manager/text/deploy?path=%2Fapi&update=true"
# Do some variable magic to access host-specific variables
-
PREFIX=$(echo $CI_ENVIRONMENT_NAME | tr '.:/-' '_')
-
HOST_VAR=${PREFIX}__HOST TOMCAT_PASSWORD_VAR=${PREFIX}__TOMCAT_PASSWORD TOMCAT_USER_VAR=${PREFIX}__TOMCAT_USER
-
"
[
-z
\"
${!HOST_VAR}
\"
]
&&
echo
\"
No
configuration
for
$DEPLOY_HOST
found.
\"
&&
exit
1"
# Abort if there are too many users online
-
USER_COUNT=$(curl -fsSL ${CI_ENVIRONMENT_URL}statistics | python -c "import sys, json; data=json.loads(sys.stdin.read()); print(data['activeUsers']);")
-
"
[
\"
$USER_COUNT
\"
-ge
10
]
&&
[
-z
\"
$FORCE
\"
]
&&
echo
\"
Too
many
users
($USER_COUNT)
online.
\"
&&
exit
1"
# Deploy .war file to Tomcat
-
curl -fsS --upload-file $WAR_FILE "https://${!TOMCAT_USER_VAR}:${!TOMCAT_PASSWORD_VAR}@${!HOST_VAR}/manager/text/deploy?path=%2F${DEPLOY_CONTEXT}&update=true"
tomcat_production
:
<<
:
*deploy
environment
:
name
:
production/$PROD_DEPLOY_HOST
url
:
https://$PROD_DEPLOY_HOST/$DEPLOY_CONTEXT/
only
:
variables
:
-
$PROD_DEPLOY_HOST
# GitLab 11.0+
#- $PROD_DEPLOY_HOST =~ /^([a-z0-9-]+\.)*[a-z0-9-]+(:[0-9]+)?$/
refs
:
-
/^v[0-9]+/
-
/^[0-9]+\.[0-9]+$/
before_script
:
-
DEPLOY_HOST=$PROD_DEPLOY_HOST
tomcat_development
:
<<
:
*deploy
environment
:
name
:
development/$DEV_DEPLOY_HOST
url
:
https://$DEV_DEPLOY_HOST/api/
only
:
variables
:
-
$DEV_DEPLOY_HOST
# GitLab 11.0+
#- $DEV_DEPLOY_HOST =~ /^([a-z0-9-]+\.)*[a-z0-9-]+(:[0-9]+)?$/
before_script
:
-
DEPLOY_HOST=$DEV_DEPLOY_HOST
sonarqube
:
stage
:
deploy
only
:
-
staging
-
master
tags
:
-
curl
-
maven
dependencies
:
-
compile
-
unit_test
cache
:
*maven_cache
allow_failure
:
true
script
:
-
curl --fail --upload-file $WAR_FILE "https://$DEV_TOMCAT_USER:$DEV_TOMCAT_PASSWORD@$DEV_TOMCAT_HOST/manager/text/deploy?path=%2Fapi&update=true"
-
mvn -B sonar:sonar
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment