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







Saturday, October 16, 2010

BugZilla: BugZilla 3.0.6 Configuration


# configure BugZilla as administrator

# Parameters Link

Required Settings

            Maintainer: bugzilla@fedora12.local.lab
            Urlbase: http://fedora12.local.lab

Administrative Policies

            Allowbugdeletion: off -> on

User Authentication

            Requirelogin: off -> on
            Createemailregrexp: .* 

Bug Change Policies

            Letsubmitterchoosepriority: on -> off
            Letsubmitterchoosemilestone: on -> off
            Commentoncreate: off -> on
            Commentonreopen: off -> on

Bug fields

            Defaultpriority: P5 -> P3
            Defaultseverity: enhancement -> normal

Group Security

            Makeproductgroups: off -> on
            Useentrygroupdefault: off -> on

Email

            Mail_delivert_method: Sendmail -> SMTP

Query Defaults

            Specific_search_allow_enpty_words: off -> on

User Matching

            Usemenuforusers: off -> on

Default Preferences Link

After changing a  bug

            Show next bug in my list -> Show the updated bug

Products Link


Field Value Link

Resolution:

            CREATION, UNIT-TEST

# Custom Configuration 

# UNIT-TEST with comment template:

Add below code into bugzilla/template/en/default/bug/edit.html.tmpl  line 75

    /* Adds the Code Complete fields to the `comment' textarea */
  function codeComplete() {
      var codeCompleteText = "Solution Description  (component(s) modified: MAC,phyD, phy, etc):\n";

      codeCompleteText += "Affected files:\n";
      codeCompleteText += "Branch where fix is located:\n";
      codeCompleteText += "Root branch (Where did the above branch originate from?) and revision:\n";
      codeCompleteText += "Dependencies:\n";
      codeCompleteText += "Code reviewed by:\n";
      codeCompleteText += "How was the fix tested:\n";
      codeCompleteText += "List the test cases used and/or built:\n";
      codeCompleteText += "Were the new test case put under revision control:\n";
      codeCompleteText += "What criteria is there to conclude the original issue is fixed:\n";
      codeCompleteText += "Instructions to allow Testers to Verify:\n";

      /* <textarea id="comment"> */
      var textarea = document.getElementById('comment');
      textarea.value = codeCompleteText + textarea.value;

      textarea.focus();
  }

Change bugzilla/template/en/default/bug/knob.html.tmpl line 190

          onchange="document.changeform.knob[[% knum %]].checked=true; if (this.value == 'UNIT-TEST') {codeComplete();}">
Instead of
          onchange="document.changeform.knob[[% knum %]].checked=true">

# Creation with Comment template:

Change bugzilla/template/en/default/bug/create.html.tmpl line 463

         defaultcontent = "Product:\nVersion:\nHardware platform:\nHardware revision:\nPCT or Base Station:\nPCT or Base Station software version:\n\nOverview: More detailed restatement of summary.\n\nProduct Impact:\n\nSteps to Reproduce: Minimized, easy-to-follow steps that will trigger the bug. Include any special setup steps. What is the frequency of occurrence?\n\nActual Results: What the application did after performing the above steps.\n\nExpected Results: What the application should have done, were the bug not present.\n\nBuild Date & Platform: Date and platform of the build in which you first encountered the bug.\n\nAdditional Builds and Platforms: Whether or not the bug takes place on other platforms (or browsers, if applicable).\n\nAdditional Information: Any other useful information.\n\nDoes a work around exist for the problem? If so, include steps to work around.\n\nDo you have a proposed solution to the problem? If so, include the appropriate information.\n\nAttach logs and describe as appropriate:"
Instead of
         defaultcontent = defaultcontent

# Reassign to “ASSIGNED” instead of “NEW”

Change bugzilla/process_bug.cgi line 1182

        ChangeStatus('ASSIGNED');
Instead of
        ChangeStatus('NEW');

# Resolution FIXED with comment template:

change
 to

Add below code into bugzilla/template/en/default/bug/edit.html.tmpl  line 97

    /* Adds the daily Regression fields to the `comment' textarea */
  function dailyRegression() {
      var dailyRegressionText = "Daily Regression Description:\n";

      dailyRegressionText += "Which daily build load did you test:\n";
      dailyRegressionText += "Daily build load compiled branch name and revision:\n";
      dailyRegressionText += "Dependencies:\n";
      dailyRegressionText += "How was the fix tested:\n";
      dailyRegressionText += "List the test cases used and/or built:\n";
      dailyRegressionText += "Were the new test case put under revision control:\n";
      dailyRegressionText += "What criteria is there to conclude the original issue is fixed:\n";
      dailyRegressionText += "Instructions to allow Testers to Verify:\n";

      /* <textarea id="comment"> */
      var textarea = document.getElementById('comment');
      textarea.value = dailyRegressionText + textarea.value;

      textarea.focus();
  }

Change bugzilla/template/en/default/bug/knob.html.tmpl line 190

        onchange="document.changeform.knob[[% knum %]].checked=true; if (this.value == 'UNIT-TEST') {codeComplete();}; if (this.value == 'FIXED') {dailyRegression();}">
Instead of
        onchange="document.changeform.knob[[% knum %]].checked=true; if (this.value == 'UNIT-TEST') {codeComplete();}">

# Custom fields

cf_found_in_rel



cf_closed_in_rel





cf_plannedrel

 

cf_action





cf_grouping



chgrp –R apache custom
/var/www/html/bugzilla/checksetup.pl

Saturday, October 9, 2010

BugZilla: BugZilla 3.0.6 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 Apache

[root@fedora12 ~]# yum install httpd
[root@fedora12 ~]# service httpd restart

# configure httpd

insert /etc/httpd/conf/httpd.conf with

Alias /bugzilla/ "/var/www/html/bugzilla/"

<Directory /var/www/html/bugzilla>
    AddHandler cgi-script .cgi
    Options +Indexes +ExecCGI +FollowSymLinks
    DirectoryIndex index.cgi
    AllowOverride Limit
</Directory>

# Change
DocumentRoot “/var/www/html” -> DocumentRoot “/var/www/htrml/bugzilla” for fixing firefox browser issue

# install PostgreSQL

# make sure /usr/bin/pg_config existence for DBI:Pg installation
[root@fedora12 ~]# yum install postgresql-devel               
[root@fedora12 ~]# yum install postgresql-server
# check version postgresql-8.4.5-1.fc12.i686
[root@fedora12 ~]# rpm –q postgresql                                

[root@fedora12 ~]# service postgresql initdb

[root@fedora12 ~]# su – postgres

Edit /var/lib/pgsql/data/pg_hba.conf
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
host all bugs 127.0.0.1 255.255.255.255 md5
# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

[root@fedora12 ~]# service postgresql restart

# add Postgres user

[root@fedora12 ~]# createuser -U postgres -dAP bugs
[root@fedora12 ~]# service postgresql restart
[root@fedora12 ~]# psql -h 127.0.0.1 -U bugs –W

# install bugzilla-3.0.6

[root@fedora12 ~]# cd /usr/local
[root@fedora12 ~]# tar –xvf /tmp/bugzilla-3.0.6.tzr.bzip to /usr/local
[root@fedora12 ~]# chgrp –R apache /usr/local/bugzilla-3.0.6
[root@fedora12 ~]# ln -s /usr/local/bugzilla-3.0.6 /var/www/html/bugzilla

# run checksetup.pl

[root@fedora12 ~]# /var/www/html/bugzilla/checksetup.pl --check-modules





yum install perl-CPAN
/usr/bin/perl -MCPAN -e 'install "Email::Send"'
/usr/bin/perl -MCPAN -e 'install "Email::MIME"'
/usr/bin/perl -MCPAN -e 'install "Template"'
/usr/bin/perl -MCPAN -e 'install "Email::MIME::Modifier"'
/usr/bin/perl -MCPAN -e 'install "DBI"'
/usr/bin/perl -MCPAN -e 'install "Date::Format"'

[root@fedora12 ~]# /usr/bin/perl -MCPAN -e 'install "DBD::Pg"'

Edit /var/www/html/bugzilla/localconfig
$db_pass = 'bugzilla';

[root@fedora12 ~]# /var/www/html/bugzilla/checksetup.pl
 







# Troubleshooting:

[root@fedora12 ~]# cd /var/www/html/bugzilla
./testserver.pl http://fedora12.local.lab/bugzilla
TEST-OK Webserver is running under group id in $webservergroup.
TEST-OK Got front picture.
Use of uninitialized value $response in pattern match (m//) at ./testserver.pl line 110.
Use of uninitialized value $response in pattern match (m//) at ./testserver.pl line 110.
TEST-FAILED Webserver is not executing CGI files.
TEST-OK Webserver is preventing fetch of http://fedora12.local.lab/bugzilla/localconfig.
TEST-OK GD version 2.45, libgd version 2.0.34; Major versions match.
TEST-OK GD library generated a good PNG image.
TEST-OK Chart library generated a good PNG image.
TEST-OK Template::Plugin::GD is installed.
[root@fedora12 ~]# chcon -R -t httpd_sys_content_t /var/www/html/bugzilla/

# configure SELinux

[root@fedora12 ~]# system-config-selinux
Status: enforcing -> permissive
Or
Boolean: httpd_can_network_connect_db uncheck -> checked

Enable send email

Boolean: httpd_can_sendmail uncheck -> checked

# BugZilla 3.0.6