1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Oracle PaaSのコマンドラインツール(PSM CLI)をMavenから実行する

1
Posted at

PSM CLIは、オラクルの提供するPaaSを操作するコマンドラインツールです。
PSM CLIについての詳細は、先達の記事がすでにありますので、そちらを参照ください。

本記事は、MavenからPSM CLIを実行して、ビルド成果物をOracle PaaSに自動デプロイする手順を記します。

ローカルPCの環境で動いても、実際にクラウドに乗せてみてはじめて分かる問題もあります。そういう問題の調査で、アプリを変更するたびに手動でアップロードするのは面倒くさいので、この記事の手順を組み込んでビルドからデプロイまでを自動化しておくと便利です。

準備作業

まず、PSM CLIを実行できるようにしておく必要があります。手順は上述の記事を参照してください。

POMの編集

PSM CLIをMavenから実行するために、exec-maven-pluginを使います。
今回の例では、デプロイ先のクラウドとしてOracle Application Container Cloud1(以下、ACCS)のJava EEアプリケーションを使います。

以下の内容をpom.xmlに記述します。

pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/xsd/maven-4.0.0.xsd">
    …
    <properties>
        …
        <accs-application-name>SampleApp</accs-application-name>
        <accs-runtime>javaee</accs-runtime>
        <accs-notification-email>email@example.com</accs-notification-email>
    </properties>
    …
    <build>
        <plugins>
            …
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>accs-deploy</id>
                        <phase>install</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>psm</executable>
                            <arguments>
                                <argument>accs</argument>
                                <argument>push</argument>
                                <argument>-n=${accs-application-name}</argument>
                                <argument>-i=${accs-notification-email}</argument>
                                <argument>-r=${accs-runtime}</argument>
                                <argument>-s=hourly</argument>
                                <argument>-p=${project.build.directory}/${project.build.finalName}.${project.packaging}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

<properties>配下には、環境に合わせて以下の値を記述します。

  • accs-application-name:
    • ACCSでアプリケーションを識別するための名前
  • accs-runtime:
    • ランタイム。ACCSではJava EEの他に、Java SE、Node.js、Python、PHP、Rubyなどが利用可能です
  • accs-notification-emaile:
    • デプロイの経過の通知先となるE-mailアドレス

この記述内容と同等のPSM CLIのコマンドを書くと、以下のようになります。

> psm accs push -n SampleApp -i email@example.com -r javaee -s hourly -p [ビルド成果物のパス]

デプロイ実行

上記の例では、Mavenのinstallフェーズでデプロイが実行されます。
以下のコマンドを実行すると、所定のPSM CLIのコマンドが実行されて、ACCSへのデプロイが行われます。

> mvn install

以下のような結果が返却されれば、コマンドの実行は成功です。

[INFO] --- exec-maven-plugin:1.6.0:exec (accs-deploy) @ SampleApp ---
This command might take a while to complete...
 Application:         javaee
 Status:              RUNNING
 Last Deployed On:    2017-09-27T02:09:09.211+0000
 Created On:          2017-09-22T03:53:30.203+0000
 Type:                web
 URL:                 https://javaee-gse00010221.apaas.em3.oraclecloud.com
 Job ID:              8085580

この時点では、まだクラウド側でデプロイプロセスが続いています。アプリケーションにアクセスできるようになるまでは、少し待つ必要があります。

  1. Oracle Application Container Cloud ↩

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?