9 Replies Latest reply on Oct 22, 2015 8:24 PM by Bill Robinson

    Automating the ARM Process

    Jereomy Schulz

      I have got various pieces of this to work, but not all together.


      I am trying to totally automate the ARM process using the Built-In DepotObject Property of RELEASE_STATUS.  So what I need to do is;


      1. Scan the entire DepotFolder named Linux, including all sub-folders for any object, BLPackage, NSHScript, Software etc that has the RELEASE_STATUS Property set to "Promote_To_Test".
      2. Change the ACL Template of the found Objects to the appropriate Template so it will be readable by the Test Role but no longer by the Dev role.
      3. Create a new Job based off of whatever type of object is found in Step 1 in the Jobs Folder /Linux/WhateverTheNameOfTheSubFolderTheObjectWasFoundIn
      4. Set the ACL Template on the New Job and the Folder it is put in so that the Test Role can see it but not the Dev Role.


      I need this to be done with no user input other than changing the Property so it can either be kicked off by a User or by a Scheduled Job.  I've figured out how to do the ACL Template change as long as I set a Job Parameter saying what the full path to the Depot Object is.  I've figured out how to display the value of the RELEASE_STATUS Property, but again as long as I tell it where to look.  From what I am seeing digging through the communities and documentation the blcli only works on a set folder and doesn't scan through sub-folders.  Help?

        • 1. Re: Automating the ARM Process
          Yanick Girouard

          There is no way to efficiently and recursively get all depot objects from a parent path using a blcli command. The only way I see you could do this, would be to add a new custom property to the depot object class to set the category of the objects (i.e. Unix or Windows), and to use a smartgroup with a condition checking that property to get the depot objects to process.


          Your users would have to set the value of the property for any package they want to release and the scheduled job would treat everything that it finds using the smartgroup.

          • 2. Re: Automating the ARM Process
            Jereomy Schulz

            I could make a SmartGroup off of the property, but that won't help me create the Job off of the Object in a subfolder.  It's going to be a huge mess of things very quickly if everything gets dumped into one Folder. 

            • 3. Re: Automating the ARM Process
              Yanick Girouard

              Yeah, but you wouldn't be able to create the job in the same folder as the depot object anyway, as they are two different types of objects and each have their own nodes and groups. You can't create jobs in a depot object folder.

              • 4. Re: Automating the ARM Process
                Jereomy Schulz

                Right, but I need to be able to create a job based off of what the Depot Object type is in a folder in the Jobs node based off of what the folder is named in the Depot node.  I don't want to just create a Job and stick every new job in the same root folder with no organization.  That will get unusable quickly.

                • 5. Re: Automating the ARM Process
                  Yanick Girouard

                  I see, in this case you're only bet would be a custom script that queries the database directly, with the added v_blgroup_paths view I published the code for a while back: Add this view to our of the box views: v_blgroup_paths


                  With this you could use SQL like this:


                  select do.name, g.group_paths from depot_object d
                  inner join v_blgroup_paths g on g.group_id = d.group_id
                  where g.group_path like '/Depot/Path/To/Parent/%'

                  • 6. Re: Automating the ARM Process
                    Bill Robinson

                    i think one of the unreleased blcli commands will recurse - DepotObject findAllByGroup maybe ??

                    • 7. Re: Automating the ARM Process
                      Yanick Girouard

                      That would give him the depot objects, but no the name of the exact group they are under if he needs that to define which job group the job should be created in.

                      • 8. Re: Automating the ARM Process
                        Bill Robinson

                        if you load the object you can get the group id and from there get the depot folder path.

                        • 9. Re: Automating the ARM Process
                          Bill Robinson

                          i mailed you this, but for the record here this script will create a smart group based on some properties, copy/rename packages and append a _latest or _datestamp suffix.





                          blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true

                          blcli_setoption serviceProfileName defaultProfile

                          blcli_setoption roleName BLAdmins








                          today="$(date +%Y%m%d%H%M%S)"



                          blcli_execute SmartDepotGroup createGroup "/" "${smartGroup##*/}" "tmp group" "Class://SystemObject/Depot Object" "${promoteProp}" "equals" "true"

                          blcli_execute SmartDepotGroup addCondition "${smartGroup}" "Class://SystemObject/Depot Object" "${releaseProp}" "equals" "Development"

                          blcli_execute SmartDepotGroup addCondition "${smartGroup}" "Class://SystemObject/Depot Object" "NAME" "does not end with" "_${suffix}"

                          blcli_execute SmartDepotGroup setMatchAll "${smartGroup}" true


                          blcli_execute SmartDepotGroup groupNameToId "${smartGroup}"

                          blcli_storeenv smartGroupId


                          blcli_execute DepotObject findAllHeadersByGroup ${smartGroupId}

                          blcli_execute Utility storeTargetObject depotObj

                          blcli_execute Utility listGetLastIndex

                          blcli_storeenv lastItem


                          for i in {1..${lastItem}}


                                  blcli_execute Utility setTargetObject depotObj

                                  blcli_execute Utility listItemSelect ${i}

                                  blcli_execute Utility setTargetObject

                                  blcli_execute SDepotObjectHeader getDBKey

                                  blcli_storeenv objKey

                                  blcli_execute SDepotObjectHeader getGroupId

                                  blcli_storeenv groupId

                                  blcli_execute SDepotObjectHeader getObjectTypeId

                                  blcli_storeenv objectTypeId

                                  blcli_execute SDepotObjectHeader getName

                                  blcli_storeenv objName

                                  blcli_execute Group findById ${groupId}

                                  blcli_execute Group getType

                                  blcli_storeenv groupTypeId

                                  blcli_execute Group getDBKey

                                  blcli_storeenv groupKey

                                  blcli_execute Group getQualifiedGroupName ${groupTypeId} ${groupId}

                                  blcli_storeenv groupPath

                                  echo "Found ${groupPath}/${objName}..."

                                  if [[ "${objName%_([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|${suffix})}" != "${objName}" ]]


                                          # if a previously release one got tagged, ignore it and set the tag to not promote.

                                          echo "${groupPath}/${objName} is not the dev one..."

                                          blcli_execute DepotObject setPropertyValue ${objKey} "${promoteProp}" "false"  


                                          # does a 'latest' exist

                                          blcli_execute DepotObject depotObjectExistsByTypeGroupAndName ${objectTypeId} ${groupKey} "${objName}_${suffix}"

                                          blcli_storeenv latestExists

                                          if [[ "${latestExists}" = "true" ]]


                                                  echo "Renaming ${groupPath}/${objName}_${suffix} to ${groupPath}/${objName}_${today}..."

                                                  blcli_execute DepotObject getDBKeyByTypeGroupAndName ${objectTypeId} "${groupPath}" "${objName}_${suffix}"

                                                  blcli_storeenv latestKey

                                                  blcli_execute DepotObject findByDBKey ${latestKey}

                                                  blcli_execute Utility storeTargetObject obj

                                              blcli_execute DepotObject setName "${objName%_${suffix}}_${today}"
                                              blcli_execute DepotObject update NAMED_OBJECT=obj
                                      echo "Copying ${groupPath}/${objName} to ${groupPath}/${objName}_${suffix}..."
                                      blcli_execute DepotObject copyDepotObject ${objKey} "${groupPath}" "${objName}_${suffix}"
                                      # unset promotion on original object


                                      #blcli_execute DepotObject setPropertyValue ${objKey} "${promoteProp}" "false"
                                      # unset promotion on new object
                                      blcli_execute DepotObject getDBKeyByTypeGroupAndName ${objectTypeId} "${groupPath}" "${objName}_${suffix}"
                                      blcli_storeenv latestKey
                                      blcli_execute DepotObject setPropertyValue ${latestKey} "${promoteProp}" "false"
                                      # bump new object to the next state
                                      blcli_execute DepotObject setPropertyValue ${latestKey} "${releaseProp}" "QA"
                                      # uncomment to apply an acl template (that can contain an acl policy) to the object and replace current permissions
                                      #blcli_execute DepotObject applyAclTemplate ${latestKey} "${aclTemplate}" true




                          blcli_execute SmartDepotGroup deleteGroupByQualifiedName "${smartGroup}"