Autolinking of issues

On a particular transition of the workflow in Jira, it is creating a new issue (Bug). How to link the same created issue to the parent issue automatically after creation and blocks the further transition of parent issue until unless the issue(Bug) got resolved.

Use IssueLinkSevice.

IssueLinkService issueLinkService = ComponentAccessor.getComponent(IssueLinkService.class);
IssueLinkService.AddIssueLinkValidationResult result = 
    IssueLinkService.validateAddLinks(user, issue, linkName, linkKeys);
if(result.isValid()){
    issueLinkService.addLinks(user, result);
} else {
    log.error("Failed to add issue links:\n" + result.getErrorCollection());
}