• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

orctom/was-maven-plugin: Deploy artifact to one or more, local or remote WebSphe ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

orctom/was-maven-plugin

开源软件地址(OpenSource Url):

https://github.com/orctom/was-maven-plugin

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

was-maven-plugin is looking for new maintainer

was-maven-plugin Build Status Maven Central

Introduction

Maven plugin to deploy a single war or ear to one or multi local or remote WebSphere Application Server (WAS) at a single build.
Tested on WAS 8.5
Requires: WebSphere Application Server installation on host box! But no need to be configured, nor running.

Requires: JDK 6 or later

How It Works

These are the known popular ways that you can programmly have your war/ear deployed to a running WebSphere Application Server:

JMX

Using IBM specialized JMX APIs you could not only retrieve the information of the apps, but also you can do deployment.

2 jars from WebSphere are required along with your build.

  • com.ibm.ws.admin.client_x.x.x.jar (over 50MB)
  • com.ibm.ws.orb_x.x.x.jar (about 2MB)

It does NOT support all options for deployment!

Monitored Directory Deployment

Deployment by adding your packages to a monitoredDeployableApps subdirectory of an application server or deployment manager profile.

For more information, please check: http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/trun_app_install_dragdrop.html

In order to deploy to a remote WAS, you'll have to copy/upload your packages to remote host first thru sftp or other approaches.

It's turned off by default.

Ant Tasks

WebSphere provides a set of built-in ant tasks, by using which you could also programmly have your packages deployed to WAS.

http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.javadoc.doc/web/apidocs/com/ibm/websphere/ant/tasks/package-summary.html

Ant tasks are in the end been translated to jacl script and been executed in wsadmin client.

wsadmin client (what we are using)

wsadmin client tool is the most powerful and flexible tool from OPS' perspective, which locates in $WAS_HOME/bin/wsadmin.sh.

It supports 2 scripting languages: jacl (default) and jython (recommended).

It uses WebSphere built-in security (credencials) and file transfer protocal (no sftp is needed) for a remote deployment.

JMX and Ant Tasks approaches were also implemented in the beginning, but we had them removed before 1.0.2

Goal-deploy

The only goal of this plugin, it will:

  1. Check if an application with the same name already installed on target server(s)/cluster(s)
  • Uninstall it if yes
  1. Install the package to target server(s)/cluster(s)
  2. Restart target server(s)/cluster(s)

Parameters

Name Type Description
wasHome String WebSphere Application Server home. Default: ${env.WAS_HOME}, required
applicationName String Application name displayed in admin console. Default: ${project.build.finalName}
applicationNameSuffix String Will be appended to applicationName, as applicationName_applicationNameSuffix, property file only
host String Local/Remote WAS IP/domain URL. e.g. 10.95.0.100, devtrunk01.company.com, default: localhost
port String Default: 8879 (when cluster not empty); 8880 (when cluster empty)
connectorType String Default: SOAP
cluster String Target cluster name, required if target WAS is a cluster
cell String Target cell name
node String Target node name,
server String Target server name,
webservers String Target web server(s) name, comma-separated.
virtualHost String Target virtual host name
user String Account username for target WAS admin console, if global security is turned on
password String Account password for target WAS admin console, if global security is turned on
contextRoot String required for war deployment
sharedLibs String Bind the exist shared libs to ear/war, comma-separated (,)
parentLast Boolean true to set classloader mode of application to PARENT_LAST, default false
restartAfterDeploy Boolean true to restart server after deploy, false to start application directly. Default true
webModuleParentLast Boolean true to set classloader mode of web module to PARENT_LAST, default false
packageFile String The EAR/WAR package that will be deployed to remote RAS, Default: ${project.artifact.file}
failOnError Boolean Default: false Whether failed the build when failed to deploy.
verbose Boolean Whether show more detailed info in log
script String Your own jython script for deployment. Double braces for variables, such as: {{cluster}}
scriptArgs String Args that will be passed to the script
javaoption String Sample -Xmx1024m, -Xms512m -Xmx1024m
deployOptions String Sample -precompileJSPs, -precompileJSPs -deployws
preSteps Ant tasks Ant tasks that can be executed before the deployments
postSteps Ant tasks Ant tasks that can be executed after the deployments
deploymentsPropertyFile File For multi target, hold above parameters, except those in bold. Default: was-maven-plugin.properties

Generally, you need to specify at least

  • cluster for a cluster
  • server and node for a non-cluster

Single Target Server

<plugin>
  <groupId>com.orctom.mojo</groupId>
  <artifactId>was-maven-plugin</artifactId>
  <version>${latest-version}</version>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>install</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration>
        <wasHome>${env.WAS_HOME}</wasHome>
        <applicationName>${project.build.finalName}</applicationName>
        <host>localhost</host>
        <server>server01</server>
        <node>node01</node>
        <virtualHost>default_host</virtualHost>
        <verbose>true</verbose>
      </configuration>
    </execution>
  </executions>
</plugin>

Multi Target Servers

was-maven-plugin.properties

This property file contains the meta config for target WAS.
The section name will be used to identify each target WAS.

Please put was-maven-plugin.properties to the same folder as pom.xml, to make it available as ${project.basedir}/was-maven-plugin.properties

[DEFAULT]
virtualHost=default_host

[dev-trunk1]
host=devtrunk1.company.com
applicationNameSuffix=trunk1
cluster=cluster01
server=server01

[dev-trunk2]
host=devtrunk2.company.com
applicationNameSuffix=trunk2
cluster=cluster02
server=server02

[dev-trunk3]
host=devtrunk3.company.com
applicationNameSuffix=trunk3
cluster=cluster03
server=server03
virtualHost=devtrunk3_host

pom.xml

<plugin>
  <groupId>com.orctom.mojo</groupId>
  <artifactId>was-maven-plugin</artifactId>
  <version>${latest-version}</version>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>install</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration>
        <wasHome>${env.WAS_HOME}</wasHome>
        <verbose>true</verbose>
      </configuration>
    </execution>
  </executions>
</plugin>

Deploy to dev-trunk1 and dev-trunk2

mvn clean install -Ddeploy_targets=`dev-trunk1`,`dev-trunk2`

Deploy to dev-trunk2 and dev-trunk3

mvn clean install -Ddeploy_targets=`dev-trunk2`,`dev-trunk3`

Pre-Steps and Post-Steps

<plugin>
  <groupId>com.orctom.mojo</groupId>
  <artifactId>was-maven-plugin</artifactId>
  <version>${latest-version}</version>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>install</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration>
        <wasHome>${env.WAS_HOME}</wasHome>
        <verbose>true</verbose>
        <preSteps>
          <target name="pre 1">
            <echo message="====== pre 1 ===== ${applicationName}" />
          </target>
          <target name="pre 2">
            <echo message="====== pre 2 =====" />
          </target>
        </preSteps>
        <postSteps>
          <target name="post 1">
            <echo message="====== post 1 =====" />
          </target>
          <target name="post 2">
            <echo message="====== post 2 =====" />
            <sleep seconds="10"/>
          </target>
        </postSteps>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>ant-contrib</groupId>
      <artifactId>ant-contrib</artifactId>
      <version>20020829</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-jsch</artifactId>
      <version>1.8.4</version>
    </dependency>
    <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
      <version>0.1.49</version>
    </dependency>
  </dependencies>
</plugin>
  • pre-steps/post-steps can be used with both single target server and multi target servers
  • All properties defined in properties section of pom or in was-maven-plugin.properties are available in pre-steps/post-steps ant tasks

Customized Jython Script File

This plugin also supports customized jython script if you need to tween the installation options, such server mappings.

You can copy-create it from the built-in one, or write a totally different one of you own.

Double braces for variables, such as: {{cluster}}, properties in was-maven-plugin.properties are all available as variables.

<plugin>
  <groupId>com.orctom.mojo</groupId>
  <artifactId>was-maven-plugin</artifactId>
  <version>${latest-version}</version>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>install</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration>
        <wasHome>${env.WAS_HOME}</wasHome>
        <script>your-jython-script.py</script><!-- relative path to project root, or absolute path starts with a "/" (Linux) or "\" (Windows)  -->
        <scriptArgs>optional-args</scriptArgs><!-- "-o deploy" will be appended if not specified. -->
        <verbose>true</verbose>
      </configuration>
    </execution>
  </executions>
</plugin>

Continues Deployment with Jenkins

We could move this plugin to a profile, and utilize Extended Choice Parameter plugin to make this parameterized.

Sample pom.xml

<profiles>
  <profile>
    <id>deploy</id>
    <activation>
      <property>
        <name>deploy</name>
        <value>true</value>
      </property>
    </activation>
    <build>
      <plugins>
        <plugin>
          <groupId>com.orctom.mojo</groupId>
          <artifactId>was-maven-plugin</artifactId>
          <version>${latest-version}</version>
          <executions>
            <execution>
              <id>deploy</id>
              <phase>install</phase>
              <goals>
                <goal>deploy</goal>
              </goals>
              <configuration>
                <wasHome>${env.WAS_HOME}</wasHome>
                <verbose>true</verbose>
                <preSteps>
                  <target name="unzip-Config-zip">
                    <echo message="Unzipping ${project.build.directory}/Config.zip --> WAS shared libs folder" />
                    <unzip dest="${WAS shared libs folder}/conf">
                      <fileset dir="${project.build.directory}/">
                        <include name="Config.zip" />
                      </fileset>
                    </unzip>
                  </target>
                  <target name="unzip-static-zip">
                    <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
                    <if>
                      <available file="${project.build.directory}/static.zip" />
                      <then>
                        <echo message="Unzipping ${project.build.directory}/static.zip --> apache sratic path" />
                        <unzip dest="${apache sratic path}" src="${project.build.directory}/static.zip" />
                      </then>
                    </if>
                  </target>
                  <target name="copy-config-to-remote">
                    <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
                    <if>
                      <isset property="some property name in pom or was-maven-plugin/properties" />
                      <then>
                        <echo message="Coping ${WAS shared libs folder}/conf to ${remote ip}:${WAS shared libs folder}/conf ..." />
                        <scp todir="wsadmin@${remote ip}:${WAS shared libs folder}/conf" keyfile="${user.home}/.ssh/id_rsa" trust="true" failonerror="false">
                          <fileset dir="${WAS shared libs folder}/conf" />
                        </scp>
                        <echo message="Copied ${meta.config.path}/conf" />
                      </then>
                      <else>
                        <echo message="Skipped, not needed." />
                      </else>
                    </if>
                  </target>
                </preSteps>
              </configuration>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>ant-contrib</groupId>
              <artifactId>ant-contrib</artifactId>
              <version>20020829</version>
            </dependency>
            <dependency>
              <groupId>org.apache.ant</groupId>
              <artifactId>ant-jsch</artifactId>
              <version>1.8.4</version>
            </dependency>
            <dependency>
              <groupId>com.jcraft</groupId>
              <artifactId>jsch</artifactId>
              <version>0.1.49</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Sample Jenkins Job Configuration

Configure

Jenkins Job configure

Trigger

Jenkins Job Trigger

With Global Security Turned on

When Global Security is enabled on remote WAS (not under a same deployment manager), certificates of remote WAS need to be added to local trust store. We could configure WAS to prompt to add them to local trust store.

  1. Open ${WAS_HOME}/properties/ssl.client.props
  2. Change the value of com.ibm.ssl.enableSignerExchangePrompt to gui or stdin
  • gui: will prompt a Java based window, this requires a X window installed.
  • stdin: when using ssh, or on client linux without X window installed.

Change Log

1.1.3.3

  • Added system property support for defining the deployments property file. #19

1.1.3.2

  • Added support for IHS webserver mapping for standalone WAS.

1.1.3.1

1.1.2

  • Fixed issue for workspace path includes whitespaces.

1.1.1

  • Fixed issue of not starting application on standalone WAS (restartAfterDeploy=false)

1.1.0

  • Fixed server mapping issue with cluster. Apps will be deployed to all servers that managed by the specified cluster.
  • Web servers support, use webservers to specify the web server(s) that you want to bind. (but you still have to 'update web server plug-in configuration' by your self.)
  • Added parameter deployOptions, expecting space-separated options such as -precompileJSPs -deployws, which will be prepended in the deployment options.
  • Fixed issue about failOnError.
  • Extracted some common code including websphere.py to was-util, which is also been used by was-gradle-plugin

1.0.12

  • Fixed the issue about "Template 'jython\websphere.py' not found" specific for Windows.

1.0.11

  • Fixed the issue with customized script.

热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap