Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt

Enables you to add a button to the page when clicked on which the SIL script is called. This is a great way for Jira and Confluence integration. 

Note, ButtonScriptMacro is available starting with version 1.1.15. Now, you are able to call any SIL script in your Confluence just with one click or even integrate Confluence and Jira if you have Power Scripts installed for both instances.

Example

Let’s say, you want to create an Issue in your Jira Project by clicking on the button on the Confluence page.

...

.

...

1. Writing the code in Jira

  1. To create a script, go to Jira Administration → Manage apps →  cPrime Tools, and click SIL Manager.
  2. Click the silprograms folder and then New  New file
  3. Create a new SIL file and name it, for example, Create_Issue.sil like in the image below. 
    Image Removed
    Image Added


  4. In the Create_Issue.sil file that you created write the script for your future tickets. This script is stable and retrieves data you have to specify in Confluence. This is an example.
    Then click Check and Save.

    Code Block
    string issue_priority;//Possible values:projectKey = "Major",";
    string parentIssueKey = "Critical";
    etc.
    string issue_description;
    string issue_security_levelissueType = "";
    string projectissueSummary = "SSTP";
    issue_string priority = "Critical";
    issue_string description = "Reproducing the issue";
    issue_security_level";
    string components = {};
    string dueDate = "";
    string estimate = "Administrator";
    string securityLevel = "";
    string k = createIssue(
    					project,
    					"", // passing in empty to create a regular issue rather than subtask
    					"Bug",
    					"PS-Summary is here" ,
    					issue_priority,
    					issue_description,
    					{}, // no components
    					currentDate() + "30d",
    					"1h 30m",
    					issue_security_level,
    					{} // and no custom field mappings
    					);
    
    print ("On the project " + project + ", issue " + k + "is created." fieldMappings = {};
    
    if(isNotNull(getElement(argv, 0)))
      projectKey = getElement(argv, 0);
    
    if(isNotNull(getElement(argv, 1)))
      parentIssueKey = getElement(argv, 1);
      
    if(isNotNull(getElement(argv, 2)))
      issueType = getElement(argv, 2);
      
    if(isNotNull(getElement(argv, 3)))
      issueSummary = getElement(argv, 3);
      
    if(isNotNull(getElement(argv, 4)))
      priority = getElement(argv, 4);
      
    if(isNotNull(getElement(argv, 5)))
      description = getElement(argv, 5);
      
    if(isNotNull(getElement(argv, 6)))
      components = getElement(argv, 6);
      
    if(isNotNull(getElement(argv, 7)))
      dueDate = getElement(argv, 7);
      
    if(isNotNull(getElement(argv, 8)))
      estimate = getElement(argv, 8);
      
    if(isNotNull(getElement(argv, 9)))
      securityLevel = getElement(argv, 9);
      
    if(isNotNull(getElement(argv, 10)))
      fieldMappings = getElement(argv, 10);
    
    createIssue(
                projectKey,
                parentIssueKey,
                issueType,
                issueSummary ,
                priority,
                description,
                components,
                dueDate,
                estimate,
                securityLevel,
                fieldMappings
              );
    


  5. You can find more information about managing your SIL Scripts on the SIL Manager page.

...

  1. To configure it, go to Confluence Administration → Add-ons →  cPrime Tools → Remote Systems and click Add Remote.
  2. You are required to enter the following information:



    Where:

    Name - is the name of the remote system, unique within other remote systems.
    URL - represents the URL (just the base URL, as shown above).
    Username & Password - to care about authentication.
    The timeout is optional, as well as the check result parameters. They control the underlying library responsible for performing REST calls. More information is here.

...

  1. To create a script, go to Confluence Administration → Add-ons  cPrime Tools, and click SIL Manager.
  2. Click the silprograms folder and → Test → and then New  New file
  3. Create a new SIL file and name it, for example,   silButtonEpic_issue.sil like in the image below. 
    Image Removed
    Image Added


  4. In the silButtonEpic_issue.sil file that you created write the following script. It calls , you have to specify the necessary parameters and add values for fields of your future issue. Also, it requests to add call routine to push your Sil script in Jira

  5. The first parameter is the name of our connection.

  6. The second parameter is the name of the script which will be executed on the remote. You have to specify all folders after silprograms (if any) as a path to the file

    .

     

    Then click Check and Save.

    Code Block
    string projectKey = "SSTP";
    string parentIssueKey = "";
    string issueType = "Epic";
    string issueSummary = "Development process";
    string priority = "Critical";
    string description = "This issue was created via SIL button";
    string components = {};
    string dueDate = currentDate() + "30d";
    string estimate = "1h 30m";
    string securityLevel = "10000";
    string fieldMappings = {};
    
    string [] args;
    
    args+=projectKey;
    args+=parentIssueKey;
    args+=issueType;
    args+=issueSummary;
    args+=priority;
    args+=description;
    args+=components;
    args+=dueDate;
    args+=estimate;
    args+=securityLevel;
    args+=fieldMappings;
    
    
    call("Test_Jira", "examples/mh_test/create_issue.sil", 
    ""
    args);
    



4. Creating a ButtonScriptMacro

...

  1. To add a ButtonScriptMacro, go to the necessary Confluence page, click Insert more content, and select Other macros →  SIL button.




  2. In the displayed dialog, fill out the necessary fields:
    1. Enter the name for the button.
    2. Enter the script name that you created in Confluence. You have to specify the full path to the program being run (all folders after silprograms (if  if any) as a path to the file.
    3. Enter the input - space key and the page name where you want to display the button (optional).
    4. Check Reuse if you want the button to remain active after execution.
      Image Removed
      Image Added


  3. Click Save to create a ButtonScriptMacro.
    Image Removed
    Image Added


Result

When you click the button, Sil script will be called and an Issue will be created. After thatDepending on settings, the button will stay active or be disabled and the comment will be added to the page. 
Image RemovedIf you check the Reuse option in the macro configuration, the button will be active and can be reused.
Image Removedafter use.

Image Added


Info

Note, it is possible to bind one button to one script per page. In other words, you are not able to have several ButtonScriptMacros are connected to the same script on the page.

...