It's all about the answers!

Ask a question

How to capture RTC change set id automatically via SCM CLI


anoop mc (74810159213) | asked Oct 05 '17, 2:40 a.m.
retagged Oct 06 '17, 3:59 p.m. by Ken Tessier (84117)

Hi,


We are using SCM CLI for creating work spaces, check in, deliver etc.

When ever we do a check action a unique change set id will be generated.

How to capture the new change set id automatically.

Here each time we need to run the command scm show status then capture the change set id.

7 answers



permanent link
Shashikant Padur (4.2k27) | answered Oct 05 '17, 4:48 a.m.
JAZZ DEVELOPER
edited Oct 05 '17, 4:49 a.m.

When you run the checkin command use the -j/--json option. Post that you can parse the json output to retrieve the new change set id.


Comments
anoop mc commented Oct 05 '17, 11:10 a.m.

will try out and see how it goes


anoop mc commented Oct 07 '17, 1:33 p.m.
Here is your article which talks about the same. 

permanent link
Shashikant Padur (4.2k27) | answered Oct 08 '17, 11:29 p.m.
JAZZ DEVELOPER

 'outgoing-changes' contains the list of change sets and each change sets have list of changes. In your case the change set id is listed in the following path:

{
  "workspaces": [
    {
      "components": [
        {
          ...
         "outgoing-changes": [
            {
              ...
              "uuid": "_fh_8oKwMEeewLNKffOsvgQ"
            }
          ],
        }
      ],
    }
  ]
}


Comments
anoop mc commented Oct 09 '17, 2:34 a.m.

 ./scm.sh add wi "_fh_8oKwMEeewLNKffOsvgQ" 10565

Link created.

This worked.


anoop mc commented Oct 09 '17, 6:02 a.m.

 What do you suggest here to capture the change_set automatically upon each check in.


suppose if we create a variable it should look inside the JSON script for what type and how it can determine the change-set UUID


anoop mc commented Oct 11 '17, 9:54 a.m.

 

change-set UUID will be stored inside this object value pair
['workspaces'][0]['components'][0]['outgoing-changes'][0]['uuid'])


permanent link
Ulf Arne Bister (1.3k112) | answered Oct 05 '17, 4:37 a.m.

Hi,

the way to capture the new change set id automatically is indeed via >scm show status and then parse the output. You will alway have to embed your scm commands in some scripting for parsing and conditions.
Alternatively you can create the change set first (and then capture and parse the output of that command:
https://jazz.net/help-dev/clm/index.jsp?topic=%2Fcom.ibm.team.scm.doc%2Ftopics%2Fcreate_changeset_ex.html
and use that as input for a >scm checkin -c <changeset_id> ...

- Arne


Comments
anoop mc commented Oct 05 '17, 11:09 a.m.

 upon each check-in action a new change set id will get generated. Not sure how the above solution will help


permanent link
anoop mc (74810159213) | answered Oct 08 '17, 6:11 a.m.
edited Oct 08 '17, 6:14 a.m.

As a part of testing these commands out, we did check-in a file  then  ran the below command using the -j option.


Now from here how will I determine which is my change-set ID

[root@linux eclipse]# ./scm.sh status -j
{
    "workspaces": [
        {
            "components": [
                {
                    "baseline": {
                        "id": 1,
                        "name": "Initial Baseline",
                        "uuid": "_reWPU6wLEeewLNKffOsvgQ"
                    },
                    "flow-target": {
                        "incoming-flow": {
                            "name": "Project_Test_Stream",
                            "type": "STREAM",
                            "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                            "uuid": "_VVsf8KkHEeewLNKffOsvgQ"
                        },
                        "name": "Project_Test_Stream",
                        "outgoing-flow": {
                            "name": "Project_Test_Stream",
                            "type": "STREAM",
                            "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                            "uuid": "_VVsf8KkHEeewLNKffOsvgQ"
                        },
                        "type": "STREAM",
                        "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                        "uuid": "_VVsf8KkHEeewLNKffOsvgQ"
                    },
                    "incoming-addition": false,
                    "incoming-changes": [
                    ],
                    "incoming-deletion": false,
                    "is_comp_loaded": true,
                    "name": "payments",
                    "outgoing-addition": false,
                    "outgoing-changes": [
                        {
                            "author": "",
                            "changes": [
                                {
                                    "inaccessible-change": false,
                                    "merges": [
                                    ],
                                    "path": "\/payments1.jar",
                                    "state": {
                                        "add": true,
                                        "conflict": false,
                                        "content_change": false,
                                        "delete": false,
                                        "move": false,
                                        "potential_conflict": false,
                                        "property_change": false
                                    },
                                    "state-id": "_fnW9xKwMEeewLNKffOsvgQ",
                                    "uuid": "_fehx4KwMEeeRDP50Db78yA"
                                },
                                {
                                    "inaccessible-change": false,
                                    "merges": [
                                    ],
                                    "path": "\/payments.jar",
                                    "state": {
                                        "add": true,
                                        "conflict": false,
                                        "content_change": false,
                                        "delete": false,
                                        "move": false,
                                        "potential_conflict": false,
                                        "property_change": false
                                    },
                                    "state-id": "_11_jJKwMEeewLNKffOsvgQ",
                                    "uuid": "_1rx3MKwMEeeMTqQSlIoxdA"
                                }
                            ],
                            "comment": "Share",
                            "modified": "08-Oct-2017 12:41 PM",
                            "state": {
                                "active": true,
                                "complete": false,
                                "conflict": false,
                                "current": true,
                                "current_merge_target": false,
                                "has_source": false,
                                "is_linked": false,
                                "is_source": false,
                                "potential_conflict": false
                            },
                            "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                            "uuid": "_fh_8oKwMEeewLNKffOsvgQ"
                        }
                    ],
                    "outgoing-deletion": false,
                    "suspended": [
                    ],
                    "type": null,
                    "uuid": "_reCtUqwLEeewLNKffOsvgQ"
                }
            ],
            "flow-target": {
                "incoming-flow": {
                    "name": "Project_Test_Stream",
                    "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                    "userId": "223994",
                    "uuid": "_VVsf8KkHEeewLNKffOsvgQ"
                },
                "name": "Project_Test_Stream",
                "outgoing-flow": {
                    "name": "Project_Test_Stream",
                    "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                    "userId": "223994",
                    "uuid": "_VVsf8KkHEeewLNKffOsvgQ"
                },
                "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
                "userId": "223994",
                "uuid": "_VVsf8KkHEeewLNKffOsvgQ"
            },
            "name": "user_worspace1",
            "type": "WORKSPACE",
            "url": "https:\/\/ratdev.corp.abc.com:9443\/ccm\/",
            "userId": "223994",
            "uuid": "_aJFMoKwLEeewLNKffOsvgQ"
        }
    ]


Comments
Shashikant Padur commented Oct 09 '17, 7:04 a.m.
JAZZ DEVELOPER

I posted the response to this as a comment above. For reason, when I try to put it here I hit the character limit.


permanent link
anoop mc (74810159213) | answered Oct 11 '17, 9:45 a.m.
edited Oct 11 '17, 9:47 a.m.

 Finally we were able to achieve close to our requirement.


Sharing those information as it might be useful for someone.

./scm.sh checkin ledger.jar  
   
./scm.sh status -j  > /root/jazz/smtools/eclipse/data.json    (Here you are directing the JSON output of the command using -j parameter to a file called data.json)

Note: Once you got the data inside the data.json file - the change-set UUID will be stored inside this object value pair
['workspaces'][0]['components'][0]['outgoing-changes'][0]['uuid'])

changeset= /usr/bin/python /root/jazz/scmtools/eclipse/script.py  (have written a python script which refer to the object value - ['workspaces'][0]['components'][0]['outgoing-changes'][0]['uuid'] and capture the UUID of outgoing change-set) and capture the UUID of outgoing changeset

echo $changeset  (displaying the output of the variable)

./scm.sh add wi "$changeset" <work item ID>  (Now we were able to substitute the change-set value with a variable called $changeset)

 ./scm.sh deliver --source userWorkspace1  --target "ABC_DEVOPS_SCM Stream"  (Finally you can try to deliver)

This helped us to capture the RTC change-set ID automatically and deliver to the stream.


permanent link
anoop mc (74810159213) | answered Oct 17 '17, 12:19 p.m.
edited Oct 18 '17, 5:30 a.m.

Now we came across a strange issue where the scm is not showing the status.


In the case above we are able to login, share files successfully, run check in command.

When running ./scm.sh status it not showing anything. Are we missing something.

Verified all the permissions all seem to be fine.  Let me know if there is any workaround to this issue.


Comments
anoop mc commented Oct 17 '17, 12:22 p.m.

 In the above post you may see the same command was working fine for me. 


permanent link
anoop mc (74810159213) | answered Oct 18 '17, 5:23 a.m.

 Look like this is due to permission issue in RTC. Last day when the user was given full rights in RTC SCM project area.


It started working again. Now that we are able to see the status command update.

./scm.sh status


./scm.sh show status
Workspace: (1005) "anoop_workspace1" <-> (1001) "ABC_Test_Stream"
  Component: (1006) "Demo1"
    Baseline: (1007) 1 "Initial Baseline"
    Outgoing:
      Change sets:
        (1008) -*--@  "Share" 18-Oct-2017 09:36 AM
  

Your answer


Register or to post your answer.