Harvest

 View Only
  • 1.  Checkout for Concurrent update UDP

    Posted Nov 27, 2023 07:06 AM

    Good day,

    This is going to sound counter-intuitive, but I have my reasons.

    I need a UDP that will check if an item is currently checked out, or if a branch version exists in any state of a project. It would be helpful if it can also provide the user to whom the item is checked out. In certain circumstances I want to prevent concurrent check-outs. However, I don't want to remove concurrent checkouts altogether for that project.

    Kind regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------


  • 2.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted Nov 28, 2023 09:25 AM

    Hello Jarus,

    You should check out the "hsv" command.  It's similar to the "find versions" tool in Workbench.  I think you have to give it a specific state name in your search, but if all new versions originate from the same state, you can search that state and find it no matter where the package is in the lifecycle.  Here's where you can read more: hsv Command-Select Version

    Let me know if this helps.

    Thanks :)

    Melinda



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 3.  RE: Checkout for Concurrent update UDP

    Posted Jan 31, 2024 06:38 AM

    Hi Melinda,

    This solution would work if I was able to send the item name and extension to my UDP. However, I only have the ["version"] system variable available, which includes the full path and version number, separated by a semicolon. I find it redundant to have to strip out the item name and extension, this should be provided by Harvest when invoking UDP's. Or am I missing something?

    Regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 4.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted Jan 31, 2024 09:54 AM

    Which operating system is your UDP running in?  I have an idea of maybe running HSV at a broader level - like getting all the files in the state and then "grepping" the result for the file you want.  I will do some testing to see if this might work for what you want to do.

    Thanks :)



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 5.  RE: Checkout for Concurrent update UDP

    Posted Feb 01, 2024 01:32 AM

    Hi Melinda,

    We're running on Linux, so my UDP runs a bash script. Your solution above doesn't help, as I still don't have the filename and extension. I've managed to parse it like this:

    #!/bin/bash
    
    # Input string without drive letter (e.g., "\path\to\file.txt;1.23")
    input_string="\path\to\file.txt;1.23"
    
    # Replace backslashes with forward slashes
    normalized_path=$(echo "$input_string" | sed 's/\\/\//g')
    
    # Extract file name and version number
    file_name_with_extension=$(basename "$normalized_path" | cut -d ';' -f 1)
    version_number=$(basename "$normalized_path" | cut -d ';' -f 2)
    
    # Extract file name without extension
    file_name_without_extension=$(echo "$file_name_with_extension" | cut -d '.' -f 1)
    
    # Display results
    echo "File Name with Extension: $file_name_with_extension"
    echo "File Name without Extension: $file_name_without_extension"
    echo "Version Number: $version_number"
    

    I still believe there should be a system variable that returns just the item's filename and extension, without the path and version. I need this in almost all of my UDP's.

    Kind regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 6.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted Feb 01, 2024 11:39 AM

    Do you know the name of the file you're looking for?



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 7.  RE: Checkout for Concurrent update UDP

    Posted Feb 02, 2024 12:22 AM

    No, because it's a UDP that can be run on any item. That's why I need a System Variable that returns the item's filename and extension.



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 8.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted Feb 05, 2024 02:35 PM

    You're right.  Harvest does not offer a system variable that can return only the file name without path or version.  That would have to be an enhancement request.

    For now, all I can offer is an easier way to parse the results you get back from the [version] variable so that you get the parts of the result you need.  You and I are thinking along similar lines.  Here's what I came up with:

    $ cat test.sh
    foo=$1
    wholename=$(echo ${foo##*\\} | cut -d';' -f1) ; echo This should remove path and version: $wholename
    filename=${wholename%.*} ; echo This should be the filename only: $filename
    extension=${wholename##*.} ; echo This should be the file extension: $extension
    $

    And it produces this result:

    $ ./test.sh "\SampleRepository\DOCS\README.1.2.3.TXT;1"
    This should remove path and version: README.1.2.3.TXT
    This should be the filename only: README.1.2.3
    This should be the file extension: TXT
    $

    It works with traditional filenames as well:

    $ ./test.sh "\SampleRepository\DOCS\README.TXT;1"
    This should remove path and version: README.TXT
    This should be the filename only: README
    This should be the file extension: TXT
    $

    Let me know if this helps.

    Thanks :)

    Melinda Skelton
    Broadcom Support Team



    ------------------------------
    Melinda Skelton
    [JobTitle]
    [CompanyName]
    ------------------------------



  • 9.  RE: Checkout for Concurrent update UDP

    Posted Mar 12, 2024 02:50 PM

    Hi Melinda,

    I finally had some more time to work on this, and I've now made it work using your hsv suggestion. I simply get the latest in branch and latest in trunk for the Development view using hsv. If the latest branch version < latest trunk version, it means that all changes have been promoted to Production and I exit 0 my script. If latest branch version > trunk version, there are still some changes not in production, so I then check if the current user attempting the checkout is the same as the user that made the branch change (info retrieved from hsv). If the user is the same, exit 0, else exit 1. Since this is pre-link for checkout, checkout will fail if another user made changes. This prevents concurrent update.

    I've used awk successfully in parsing the hsv results to retrieve all the fields I need (modify user, package name, version, modified date).

    Thank you very much for your help!

    Regards,

    Jarus



    ------------------------------
    Jarus Bosman
    Senior Software Developer
    State Information Technology Agency
    South Africa
    ------------------------------



  • 10.  RE: Checkout for Concurrent update UDP

    Broadcom Employee
    Posted Mar 13, 2024 08:06 AM
    Excellent news!!!!

    --

    Melinda Skelton

    Sr Principal Support Engineer

    Broadcom Agile Operations Division

    Office: +1 469-497-4867 | Cell: +1 469-748-2723

    5465 Legacy Drive Suite 700 | Plano, TX 75024-3106

    melinda.skelton@broadcom.com | broadcom.com

    --
    This electronic communication and the information and any files transmitted
    with it, or attached to it, are confidential and are intended solely for
    the use of the individual or entity to whom it is addressed and may contain
    information that is confidential, legally privileged, protected by privacy
    laws, or otherwise restricted from disclosure to anyone else. If you are
    not the intended recipient or the person responsible for delivering the
    e-mail to the intended recipient, you are hereby notified that any use,
    copying, distributing, dissemination, forwarding, printing, or copying of
    this e-mail is strictly prohibited. If you received this e-mail in error,
    please return the e-mail to the sender, delete it from your computer, and
    destroy any printed copy of it.