Thursday, May 25, 2017

Moving Jira tickets to Github automation

When you need to move your existing issue list from Jira to Github the following project will come in handy.

https://github.com/amalhub/github-automation

The project has been made to automate the process of moving Jira tickets to Github issues. In this approach I've used the Jira issue list export functionality to export the issue list into an XML file and then using the Github API, I have automated the process of pushing the issue list into Github.

If you want to perform a bulk operation on the moved Jira issues refer Editing multiple Jira issues at the same time. Using this functionality you can add a comment in the Jira directing the user to the Github issue list (Since the Git issue header contains the Jira issue id user can easily search for it).

Example comment: "Moved to Github issues: ${link}. Search with Jira issue ID to find it in Git."

Follow the ReadMe file in the project and you will be done with the process in no time!

Happy Coding!!

Friday, May 19, 2017

Maven build, how to replace only a part of regexp match

The following configuration will be useful when you need to replace a subsection of a regular expression match in a file at maven build.

Usecase scenario:

Let's say you have a configuration file (conf.properties) with set of properties and you need to update the properties only related to ios.

Sample data:
carbon.device.mgt.input.adapter=false
carbon.device.mgt.ios.api=flase
carbon.device.mgt.ios.apns=false
carbon.device.mgt.ios.core=false
carbon.device.mgt.mobile.android=false
Expected outcome:
carbon.device.mgt.input.adapter=false
carbon.device.mgt.ios.api=true
carbon.device.mgt.ios.apns=true
carbon.device.mgt.ios.core=true
carbon.device.mgt.mobile.android=false
This is achievable by the maven-antrun-plugin.

Sample configuration:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>default-feature-install</id>
            <phase>package</phase>
            <configuration>
                <target>
                    <replaceregexp file="conf.properties" match="(ios.*)false" replace="\1true" byline="true"/>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Regular expression justification:

  • match="(ios.*)false"
    • The following regular expression will select the string that contains "ios" and "false".
    • But we only need to replace the "false" value to "true" in the regular expression selection.
    • Therefore I have grouped the selection using brackets so that it can be referenced in the substitution expression.
  • replace="\1true"
    • In the following substituion string I have used the "\1" to define that I need to include the 1st group selection as part of the replacement string. 
    • The rest of the selection will get replaced by the new value.
Happy coding !!!