-
-
Save jesusjavierdediego/c10d401bdd8970ffdbeb6a05c5e9c560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@throws(classOf[JIRAException]) | |
def getJIRARESTClient(): Option[JiraRestClient] = { | |
try { | |
val asyncClientFactory: AsynchronousJiraRestClientFactory = new AsynchronousJiraRestClientFactory() | |
result = Some(asyncClientFactory.createWithBasicHttpAuthentication( | |
new URI(baseUrl), | |
jiraUser, | |
jiraPwd | |
)) | |
}catch{ | |
case(e: Exception) => { | |
logger.error(s"The atlassian jira erest client could not be created. Reason: ${e}") | |
throw new JIRAException() | |
} | |
} | |
result | |
} | |
@throws(classOf[JIRAException]) | |
def createNewJIRAItemAndWriteFeatureInto(rf: RequirementFeature): Unit ={ | |
val defaultIssueType = configuration.envOrElseConfig("data.destination.jira.defaultIssueType") | |
try{ | |
val issueTypes = client.getMetadataClient.getIssueTypes.claim().asScala | |
for(it <- issueTypes) yield { | |
if(it.getName.equals(defaultIssueType)){ | |
val projectId: Long = client.getProjectClient.getProject(rf.projectKey).claim().getId | |
val newIssueInput: IssueInput = new IssueInputBuilder(rf.projectKey,it.getId, rf.jiraIssue.get.summary).build() | |
val newIssue: BasicIssue = client.getIssueClient.createIssue(newIssueInput).claim() | |
updateDescriptionIntoExistingJIRAIssue(updateJIRAItemInRF(newIssue, rf)) | |
} | |
} | |
}catch{ | |
case e: Exception => { | |
logger.error(s"Error trying to create a new JIRA issue. feature: '${rf.name}'. Reason: ${e}") | |
throw new JIRAException(s"Error trying to create a new JIRA issue. feature: '${rf.name}'. Reason: ${e}") | |
} | |
} | |
} | |
private def updateJIRAItemInRF(newIssue: BasicIssue, rf: RequirementFeature): RequirementFeature ={ | |
val newJIRAItem: JIRAIssue = new JIRAIssue(newIssue.getId, newIssue.getKey, rf.name) | |
new RequirementFeature(rf.feature_id, rf.name, rf.projectKey, rf.component, rf.scenarios, Some(newJIRAItem), rf.lastUpdateTime) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment