Skip to content
Snippets Groups Projects
Commit 5f8faba3 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

chore: Add temporary ci/cd job to investigate cli possibilities

parent 207f40a1
Branches
Tags
No related merge requests found
Pipeline #2529 failed
......@@ -15,6 +15,7 @@ variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dmaven.artifact.threads=10"
MAIN_BRANCH: "main"
RELEASE_BRANCH: "release"
CLI_PATH: "/wildfly/wildfly-25.0.1.Final/bin"
TMP_PATH: "/home/deployer/gitlab_tmp"
DEPLOYMENT_PATH: "/home/wildfly/deployments"
ARCHIVE_PATH: "/home/wildfly/archive"
......@@ -58,7 +59,7 @@ test:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
deploy-to-staging:
debug-cli:
stage: deploy
script:
# Authentication setup
......@@ -66,52 +67,9 @@ deploy-to-staging:
- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa
- 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)
- 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"
- 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"
- CURRENT_VERSION=$(ssh $SERVER_USER@$SERVER_IP "ls $DEPLOYMENT_PATH/VIPSCore-*.war | head -n 1 | sed -n 's/.*VIPSCore-\(.*\)\.war/\1/p'")
- |
if [ -n "$CURRENT_VERSION" ]; then
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"
else
echo "No matching war file found. Skip archive step."
fi
# Deploy war file using JBoss CLI and credentials given in CI/CD variables
- echo "Deploy $WAR_FILE using JBoss 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" > deployment.log 2>&1
# Restart should not be necessary
- echo "Restart WildFly"
- ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
# Delete temporary directory on server
- echo "Delete temporary directory"
- ssh $SERVER_USER@$SERVER_IP "rm -rf $TMP_PATH"
after_script:
- echo "Deployment complete"
tags:
- vips-java
rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
environment:
name: staging
url: https://vipscore02test.nibio.no
upload-snapshot:
stage: upload
script:
- export VERSION=$(./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS --batch-mode --no-transfer-progress --non-recursive help:evaluate -Dexpression=project.version | grep -v "\[.*")
- if ! [[ $VERSION =~ .*SNAPSHOT ]]; then
echo "Version '$VERSION' is not SNAPSHOT"; exit 1;
fi
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests"
- CURRENTLY_DEPLOYED=$(ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --commands=ls\ deployment | grep VIPSCore.*war")
- echo $CURRENTLY_DEPLOYED
- ssh $SERVER_USER@$CHAT_CHANNELSERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --command='undeploy $CURRENTLY_DEPLOYED'"
tags:
- vips-java
rules:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment