user3571284
user3571284

Reputation: 1

OpenShift: Not able to deploy war generated by Jenkins in Openshift to container (Tomcat) in another gear

First of all, let me inform you that this issue is related to OPENSHIFT. I'm tired of building war with Jenkins and then manually transferring the newly built war file to the server - It's time consuming.

I'm trying to deploy a maven application built from Jenkins in one gear and deploy it in the TOMCAT 7 server which is running in another gear.

I'm using Deploy container plugin via Jenkins to push my war file into the TOMCAT server after being built by the Jenkins. In the tomcat server, I edited the tomcat-users.xml.

<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="manager"/>

I tried to deploy it with JBoss AS 7 available. But could not deploy either - so decided to switch to the Tomcat with hope that deployment in tomcat is easier than in JBoss.

Upvotes: 0

Views: 834

Answers (1)

aug70co
aug70co

Reputation: 3987

Here is how you can do it with Jenkins/execute shell: (This is example is with Java/Maven but you can use it with any other stack.)

source $OPENSHIFT_CARTRIDGE_SDK_BASH
## Aliasing rsynch
alias rsync="rsync --delete-after -az -e '$GIT_SSH'"

## OPENSHIFT_NAMESPACE => redrumapi
## Setting upstream SSH
upstream_ssh="${OPENSHIFT_APP_UUID}@apiserver1-${OPENSHIFT_NAMESPACE}.rhcloud.com"

## Remove previous metadata, if any
rm -f $OPENSHIFT_HOMEDIR/app-deployments/current/metadata.json

#if ! marker_present "force_clean_build"; then
  # don't fail if these rsyncs fail
  #set +e
  rsync $upstream_ssh:'$OPENSHIFT_BUILD_DEPENDENCIES_DIR' $OPENSHIFT_BUILD_DEPENDENCIES_DIR
  rsync $upstream_ssh:'$OPENSHIFT_DEPENDENCIES_DIR' $OPENSHIFT_DEPENDENCIES_DIR
  #set -e
#fi

## Build/update libs and run user pre_build and build
##gear build

cd $OPENSHIFT_DATA_DIR
echo -e "<settings><localRepository>$OPENSHIFT_DATA_DIR.m2</localRepository></settings>" > settings.xml
cd $WORKSPACE
git pull origin master
## Build your project with the settings.xml and other switches that you might need (or not?)
mvn clean install -s $OPENSHIFT_DATA_DIR/settings.xml -P openshift -Djacoco.skip=true -DskipTests -Dbuild.number=${BUILD_NUMBER}


deployment_dir=`$GIT_SSH $upstream_ssh 'gear create-deployment-dir'`

rsync $WORKSPACE/redrum-web/target/your_project.war $upstream_ssh:app-root/runtime/repo/webapps
$GIT_SSH $upstream_ssh "gear remotedeploy --trace --deployment-datetime $deployment_dir"

Upvotes: 0

Related Questions