Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSCore
Commits
011b7564
Commit
011b7564
authored
1 year ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
chore: Document (and reorganise) ci/cd deploy
parent
d968b7d5
No related branches found
No related tags found
No related merge requests found
Pipeline
#2496
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Stage: upload
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+13
-4
13 additions, 4 deletions
.gitlab-ci.yml
with
13 additions
and
4 deletions
.gitlab-ci.yml
+
13
−
4
View file @
011b7564
...
@@ -55,14 +55,21 @@ test:
...
@@ -55,14 +55,21 @@ test:
deploy-to-staging
:
deploy-to-staging
:
stage
:
deploy
stage
:
deploy
script
:
script
:
# Authentication setup
-
mkdir -p ~/.ssh
-
mkdir -p ~/.ssh
-
echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
-
echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
-
chmod 600 ~/.ssh/id_dsa
-
chmod 600 ~/.ssh/id_dsa
-
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
-
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# Find name of war file in target folder (built previously in build stage), exit if none exists
-
WAR_FILE=$(find target -maxdepth 1 -type f -name "*.war" | sort -n | tail -1 | xargs basename)
-
WAR_FILE=$(find target -maxdepth 1 -type f -name "*.war" | sort -n | tail -1 | xargs basename)
-
if [ -z "$WAR_FILE" ]; then echo "No war file found in target directory"; exit 1; fi
-
if [ -z "$WAR_FILE" ]; then echo "No war file found in target directory"; exit 1; fi
# Create temporary directory on server, copy war file and deployment script there
-
echo "Create temporary directory on the server"
-
echo "Create temporary directory on the server"
-
ssh $SERVER_USER@$SERVER_IP "mkdir -p $TMP_PATH"
-
ssh $SERVER_USER@$SERVER_IP "mkdir -p $TMP_PATH"
-
scp target/$WAR_FILE $SERVER_USER@$SERVER_IP:$TMP_PATH
-
echo "deploy $TMP_PATH/$WAR_FILE --force" > deploy.cli
-
scp deploy.cli $SERVER_USER@$SERVER_IP:$TMP_PATH
# Find version of currently deployed appliation, archive timestamped war file. Skip if no deployed war file is found.
-
echo "Archive currently deployed application"
-
echo "Archive currently deployed application"
-
CURRENT_VERSION=$(ssh $SERVER_USER@$SERVER_IP "ls $DEPLOYMENT_PATH/VIPSCore-*.war | head -n 1 | sed -n 's/.*VIPSCore-\(.*\)\.war/\1/p'")
-
CURRENT_VERSION=$(ssh $SERVER_USER@$SERVER_IP "ls $DEPLOYMENT_PATH/VIPSCore-*.war | head -n 1 | sed -n 's/.*VIPSCore-\(.*\)\.war/\1/p'")
-
|
-
|
...
@@ -70,17 +77,19 @@ deploy-to-staging:
...
@@ -70,17 +77,19 @@ deploy-to-staging:
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
ssh $SERVER_USER@$SERVER_IP "mv $DEPLOYMENT_PATH/VIPSCore-${CURRENT_VERSION}.war $ARCHIVE_PATH/VIPSCore-${CURRENT_VERSION}-${TIMESTAMP}.war"
ssh $SERVER_USER@$SERVER_IP "mv $DEPLOYMENT_PATH/VIPSCore-${CURRENT_VERSION}.war $ARCHIVE_PATH/VIPSCore-${CURRENT_VERSION}-${TIMESTAMP}.war"
else
else
echo "No matching file found. Skip
ping
archive step."
echo "No matching
war
file found. Skip archive step."
fi
fi
# Deploy war file using JBoss CLI and credentials given in CI/CD variables
-
echo "Deploy $WAR_FILE using JBoss CLI"
-
echo "Deploy $WAR_FILE using JBoss CLI"
-
scp target/$WAR_FILE $SERVER_USER@$SERVER_IP:$TMP_PATH
-
echo "deploy $TMP_PATH/$WAR_FILE --force" > deploy.cli
-
scp deploy.cli $SERVER_USER@$SERVER_IP:$TMP_PATH
-
ssh $SERVER_USER@$SERVER_IP "/disks/data01/wildfly/wildfly-25.0.1.Final/bin/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli"
-
ssh $SERVER_USER@$SERVER_IP "/disks/data01/wildfly/wildfly-25.0.1.Final/bin/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli"
# Restart should not be necessary
-
echo "Restart WildFly"
-
echo "Restart WildFly"
-
ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
-
ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
# Delete temporary directory on server
-
echo "Delete temporary directory"
-
echo "Delete temporary directory"
-
ssh $SERVER_USER@$SERVER_IP "rm -rf $TMP_PATH"
-
ssh $SERVER_USER@$SERVER_IP "rm -rf $TMP_PATH"
after_script
:
-
echo "Deployment complete"
tags
:
tags
:
-
vips-java
-
vips-java
rules
:
rules
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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