Jira.Login Method

Applies to TestComplete 15.45, last modified on December 01, 2022

The Jira.Login method is only available if the external JiraSupport script extension is installed and enabled in TestComplete. To learn how you can do it, see Sending Issues to Jira From Script Tests.

Description

You use the Jira.Login method to connect to your Jira database.

Declaration

Jira.Login(Url, Login, Password)

Url [in]    Required    String    
Login [in]    Required    String    
Password [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Url

The JIRA server URL, including http:// or https:// and the port number (if needed). For example, http://jira:8080 or https://<yourcompany>.atlassian.net.

Login

The email address to access Jira or the name of the Jira account.

Password

The API token or the password of your Jira account. To learn how to get a Jira API token, see the Atlassian documentation.

Notes:

  • If you use an API token to access Jira, make sure the Login parameter specifies your email address (not your user name in Jira).

  • If you use a password to access your Jira server and you get an error, we recommend that you try using an API token instead. You can learn how to get an API token in the Jira documentation on the Atlassian website.

Result Value

True if you log in to your Jira account successfully, False otherwise.

Example

The code below demonstrates how you can use Jira.Login method in your script tests:

JavaScript, JScript

function IssueToJira()
{
  // Log in to Jira
  Jira.Login("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2");
  var priorityJSON = '{"name":"Low"}';
  // Create an object that defines task properties
  var jiraData = Jira.CreateNewIssueData("MyJiraProjectKey", "Task").
                setField("summary", "This is a sample task summary").
                setField("description", "Sample task description").
                setField("customfield_10700", "12.40.08").
                setFieldJSON("priority", priorityJSON);
  // Post the issue to Jira
  var key = Jira.PostIssue(jiraData);
  // Attach the desired file to the created issue
  Jira.PostAttachment(key, "C:\\temp\\MyFile.txt");
  var upPriorityJSON = '{"name":"High"}';
  // Create an object that defines updating task properties
  var upJiraData = Jira.CreateUpdateIssueData().setFieldJSON("priority", upPriorityJSON);
  // Update the issue
  Jira.UpdateIssue(key, upJiraData);
}

Python

def IssueToJira():
  # Log in to Jira
  Jira.Login("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2")
  priorityJSON = '{"name":"Low"}'
  # Create an object that defines task properties
  jiraData = Jira.CreateNewIssueData("MyJiraProjectKey", "Task").\
                setField("summary", "This is a sample task summary").\
                setField("description", "Sample task description").\
                setField("customfield_10700", "12.40.08").\
                setFieldJSON("priority", priorityJSON);
  # Post the issue to Jira 
  key = Jira.PostIssue(jiraData)
  # Attach the desired file to the created issue
  Jira.PostAttachment(key, "C:\\temp\\MyFile.txt")
  upPriorityJSON = '{"name":"High"}'
  # Create an object that defines updating task properties
  upJiraData = Jira.CreateUpdateIssueData().setFieldJSON("priority", upPriorityJSON)
  # Update the issue
  Jira.UpdateIssue(key, upJiraData)

VBScript

Sub IssueToJira
  ' Log in to Jira
  Call Jira.Login("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2")
  priorityJSON = "{""name"":""Low""}"
  ' Create an object that defines task properties
  Set jiraData = Jira.CreateNewIssueData("MyJiraProjectKey", "Task")._
                setField("summary", "This is a sample task summary")._
                setField("description", "Sample task description")._
                setField("customfield_10700", "12.40.08")._
                setFieldJSON("priority", priorityJSON)
  ' Post the issue to Jira
  key = Jira.PostIssue(jiraData)
  ' Attach the desired file to the created issue
  Call Jira.PostAttachment(key, "C:\\temp\\MyFile.txt")
  upPriorityJSON = "{""name"":""High""}"
  ' Create an object that defines updating task properties
  Set upJiraData = Jira.CreateUpdateIssueData().setFieldJSON("priority", upPriorityJSON)
  ' Update the issue
  Call Jira.UpdateIssue(key, upJiraData)
End Sub

DelphiScript

procedure IssueToJira;
var 
  priorityJSON, jiraData, key, upPriorityJSON, upJiraData;
begin
  // Log in to Jira
  Jira.Login('https://mycompany.atlassian/net/', '[email protected]', 'c40Mwj3PovmRTFZbmIiwB8C2');
  priorityJSON :='{"name":"Low"}';
  // Create an object that defines task properties
  jiraData := Jira.CreateNewIssueData('MyJiraProjectKey', 'Task').
                setField('summary', 'This is a sample task summary').
                setField('description', 'Sample task description').
                setField('customfield_10700', '12.40.08').
                setFieldJSON('priority', priorityJSON);
  // Post the issue to Jira
  key := Jira.PostIssue(jiraData);
  // Attach the desired file to the created issue
  Jira.PostAttachment(key, 'C:\temp\MyFile.txt');
  upPriorityJSON := '{"name":"High"}';
  // Create an object that defines updating task properties
  upJiraData := Jira.CreateUpdateIssueData().setFieldJSON('priority', upPriorityJSON);
  // Update the issue
  Jira.UpdateIssue(key, upJiraData);
end;

C++Script, C#Script

function IssueToJira()
{
  // Log in to Jira
  Jira["Login"]("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2");
  var priorityJSON = '{"name":"Low"}';
  // Create an object that defines task properties
  var jiraData = Jira["CreateNewIssueData"]("MyJiraProjectKey", "Task")
                ["setField"]("summary", "This is a sample task summary")
                ["setField"]("description", "Sample task description")
                ["setField"]("customfield_10700", "12.40.08")
                ["setFieldJSON"]("priority", priorityJSON);
  // Post the issue to Jira
  var key = Jira["PostIssue"](jiraData);
  // Attach the desired file to the created issue
  Jira["PostAttachment"](key, "C:\\temp\\MyFile.txt");
  var upPriorityJSON = '{"name":"High"}';
  // Create an object that defines updating task properties
  var upJiraData = Jira["CreateUpdateIssueData"]()["setFieldJSON"]("priority", upPriorityJSON);
  // Update the issue
  Jira["UpdateIssue"](key, upJiraData);
}

To interact with Jira custom fields, use their identifiers instead of the field names. In the code above, it is customfield_10700.

To call this function from keyword tests, use the Run Code Snippet operation.

See Also

CreateNewBugData Method
CreateNewIssueData Method
CreateUpdateIssueData Method
PostAttachment Method
PostIssue Method
UpdateIssue Method
Jira Object

Highlight search results