Simplest Enterprise Continuous Integration Solutions

Saturday, November 20, 2010

InstallAnywhere: customcode via NetBeans


Here are the steps for creating an InstallAnywhere CustomCode (plugin) via NetBeans.


1. NetBeans IDE creates a new "Java Application" project - CompareVersionString, with com.qxc.ia.customcode.actions.CompareVersionString Main Class


CompareVersionString.java

package com.qxc.ia.customcode.actions;

import com.zerog.ia.api.pub.*;
import java.util.Arrays;
import java.util.List;

/**
 * CompareString.java
 *
 *
 */
public class CompareVersionString extends CustomCodeAction {

    /**
     *  This is the method that is called at install-time.  The InstallerProxy
     *  instance provides methods to access information in the installer,
     *  set status, and control flow.
     */
    public void install(InstallerProxy ip) throws InstallException {
        try {
            String myVar1 = ip.substitute("$OLD_VERSION_STR$");
            String myVar2 = ip.substitute("$NEW_VERSION_STR$");
            Integer myResultVariable = null;

            if (getComparisonResults(myVar1, myVar2) == 1) {
                myResultVariable = 1;
            } else if (getComparisonResults(myVar1, myVar2) == -1) {
                myResultVariable = -1;
            } else if (getComparisonResults(myVar1, myVar2) == 0) {
                myResultVariable = 0;
            }

            ip.setVariable("$COMPARISON_RESULT$", myResultVariable);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     *  This is the method that is called at uninstall-time.  The DataInput
     *  instance provides access to any information written at install-time
     *  with the instance of DataOutput provided by UninstallerProxy.getLogOutput().
     */
    public void uninstall(UninstallerProxy up) throws InstallException {
    }

    /**
     *  This method will be called to display a status message during the
     *  installation.
     */
    public String getInstallStatusMessage() {
        return "Comparing string";
    }

    /**
     *  This method will be called to display a status message during the
     *  uninstall.
     */
    public String getUninstallStatusMessage() {
        return "Comparing string";
    }

    public static int getComparisonResults(String oldString, String newVersion) {
        oldString = oldString.replaceAll("\\s", "");
        newVersion = newVersion.replaceAll("\\s", "");
        String[] a1 = oldString.split("\\.");
        String[] a2 = newVersion.split("\\.");
        List<String> list1 = Arrays.asList(a1);
        List<String> list2 = Arrays.asList(a2);

        int i = 0;
        while (true) {
            Double digit1 = null;
            Double digit2 = null;

            try {
                digit1 = Double.parseDouble(list1.get(i));
            } catch (IndexOutOfBoundsException e) {
            }

            try {
                digit2 = Double.parseDouble(list2.get(i));
            } catch (IndexOutOfBoundsException e) {
            }

            if (digit1 != null && digit2 != null) {
                if (digit1.doubleValue() > digit2.doubleValue()) {
                    return 1;
                } else if (digit1.doubleValue() < digit2.doubleValue()) {
                    return -1;
                }
            } else if (digit2 == null && digit1 != null) {
                if (digit1.doubleValue() > 0) {
                    return 1;
                }
            } else if (digit1 == null && digit2 != null) {
                if (digit2.doubleValue() > 0) {
                    return -1;
                }
            } else {
                break;
            }
            i++;
        }
        return 0;
    }
}


2. Under Source Packages, add help.htm and customcode.properties

help.htm:

<!--
<html>
<head>
<title>Plugin</title>
</head>
<body>
<b>Custom Code Action: CompareVersionString</b>
<br>
Classname: com.qxc.ia.customcode.actions.CompareVersionString
<br>
<br>
<b>Description:</b> This class compares dot delimited two version strings.
<br>
<br>
<b>Input InstallAnywhere Variables:</b>
<br>
<br>
$OLD_VERSION_STR$: contains dot delimited version string (i.e. 1.1.0.0).
<br>
$NEW_VERSION_STR$: contains dot delimited version string (i.e. 1.1.0.1).
<br>
<br>
<b>Output InstallAnywhere Variables:</b>
<br>
<br>
$COMPARISON_RESULT$: contains comparison result
<br>
(i.e.
<br>
"1" for $OLD_VERSION_STR$ is greater than $NEW_VERSION_STR$
<br>
"-1" for $OLD_VERSION_STR$ is less than $NEW_VERSION_STR$
<br>
"0" for $OLD_VERSION_STR$ is equal to $NEW_VERSION_STR$
<br>
) .
<br>
</body>
</html>

-->

customcode.properties:

plugin.main.class=com.qxc.ia.customcode.actions.CompareVersionString
plugin.name=CompareVersionString
plugin.type=action
plugin.available=preinstall,install,postinstall,preuninstall,postuninstall
property.OLD_VERSION_STR=
property.NEW_VERSION_STR=



3. Add <InstallAnywhere Install Dir>\IAClasses.zip for import com.zerog.ia.api.pub.*


4. NetBeans "Clean and Build" to generate CompareVersionString.jar


5. Copy the CompareVersionString.jar to <InstallAnywhere Install Dir>\plugins



6. CompareVersionString plugin is avaiable now










Saturday, November 13, 2010

MySQL: get MySQL database character set

[root@linux64-jira-server ~]# mysql -u root -h linux64-jira-server -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 525
Server version: 5.5.25-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| latin1jiradb       |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "latin1jiradb";

+----------------------------+
| default_character_set_name |
+----------------------------+
| latin1                     |
+----------------------------+
1 row in set (0.00 sec)

mysql>exit
Bye

Sunday, November 7, 2010

JIRA: JIRA 4.2 on Fedora12

[root@fedora12 ~]# uname -a
Linux fedora12.local.lab 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 i686 i386 GNU/Linux

# install MySQL Server

[root@fedora12 ~]# yum install mysql mysql-server
[root@fedora12 ~]# service mysqld start
[root@fedora12 ~]# chkconfig --level 2345 mysqld on

# configure MySQL root password

[root@fedora12 ~]# mysql -u root
[root@fedora12 ~]# mysqladmin -u root password ********

# create jiradb with character set utf8

[root@fedora12 ~]# mysql -u roor -p

Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.47 Source distribution


Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> CREATE DATABASE jiradb CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on jiradb.* TO 'jira'@'localhost' IDENTIFIED BY '********';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit

# verify MySQL jiradb

[root@fedora12 ~]# mysql --user=jira --password=******** --database=jiradb
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.47 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye

# update MySQL host access

[root@fedora12 ~]# mysql -u root -p mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.47 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user, host from user
mysql> update user set host='fedora12.local.lab' where user='jira';

# create jira user/group

sudo useradd jira

# JDK 1.6 - jdk-6u22-linux-i586-rpm.bin from http://java.sun.com/javase/downloads/index.jsp

[root@fedora12 ~]# cd ~/Downloads
[root@fedora12 Downloads]# chmod +x jdk-6u22-linux-i586-rpm.bin
[root@fedora12 Downloads]# ./ jdk-6u22-linux-i586-rpm.bin
[root@fedora12 Downloads]# rpm -i jdk-6u22-linux-i586.rpm
[root@fedora12 Downloads]# ln -s /usr/java/jdk1.6.0_22/bin/java /usr/bin/java
[root@fedora12 Downloads]# ln -s /usr/java/jdk1.6.0_22/bin/javac /usr/bin/javac
[root@fedora12 Downloads]# vi /etc/profile
[root@fedora12 Downloads]# export JAVA_HOME=/usr/java/jdk1.6.0_22

# install JIRA

[root@fedora12 ~]# mkdir -p /opt/jira
[root@fedora12 ~]# chown -R jira.jira /opt/jira
[root@fedora12 ~]# chmod -R 755 /opt/jira

# login as jira to extract atlassian-jira-enterprise-4.2-standalone.tar.gz

[root@fedora12 ~]# su - jira
[jira@fedora12 ~]$ cd /tmp
[jira@fedora12 ~]$ tar -xvf atlassian-jira-enterprise-4.2-standalone.tar.gz
[jira@fedora12 ~]$ cd
[jira@fedora12 ~]$ cp -rf /tmp/atlassian-jira-enterprise-4.2-standalone/* .
[jira@fedora12 ~]$ cd /opt/jira

# configure jira.home

[root@fedora12 ~]# cat atlassian-jira/WEB-INF/classes/jira-application.properties
jira.home = /home/jira

# start JIRA

[root@fedora12 ~]# /opt/jira/bin/startup.sh
[root@fedora12 ~]# tail -f /opt/jira/logs/catalina.out








# JIRA website


http://fedora12.local.lab:8080/secure/Dashboard.jspa