none
TFS Build agent log file is not capturing environment variables

    Question

  • Hi,

    In our requirement for audit in TFS we need to capture environment variables like

    BUILD_REQUESTEDFOR, BUILD_QUEUEDBY,BUILD_QUEUEDBYID and many other. In one of project collection these details are getting logged while in other project collection it is not getting logged. Does there any reason why not getting logged or I need to enable some parameter for this.

    Please suggest how to enable these logging info to agent log file. Example of log file below where details are captured.

    [BUILD_REPOSITORY_PROVIDER] --> [TfsVersionControl]
    11:30:37.363491 BaseLogger.LogConsoleMessage(scope.JobId = b324ecae-3249-4506-87d9-562174ab51be, message = [BUILD_REQUESTEDFOR] --> [Shyamal Kumar Paul])
    11:30:37.363491 JobManager.LogConsoleMessage (scope.JobId = b324ecae-3249-4506-87d9-562174ab51be, message = [BUILD_REQUESTEDFOR] --> [Shyamal Kumar Paul])
    11:30:37.364491 JobManager.LogConsoleMessage - message enqueued
    11:30:37.364491 [03c71dfb-ff13-4f0d-9fd2-f3ce04cccb02][03d43cd7-4bdf-4f9c-80b5-ae61a9a4e42f] [BUILD_REQUESTEDFOR] --> [Shyamal Kumar Paul]
    11:30:37.364491 BaseLogger.LogConsoleMessage(scope.JobId = b324ecae-3249-4506-87d9-562174ab51be, message = [BUILD_TYPE] --> [Build])
    11:30:37.364491 JobManager.LogConsoleMessage (scope.JobId = b324ecae-3249-4506-87d9-562174ab51be, message = [BUILD_TYPE] --> [Build])
    11:30:37.364491 JobManager.LogConsoleMessage - message enqueued

    Monday, March 06, 2017 4:22 PM

All replies

  • Hi Shyamal and Ashutosh,

    Thank you for posting here.

    To get all the corresponding values of those Environment build variables, you could using a Powershell script and write like below in the powershell script:

    $requestfor = $env:TF_BUILD_REQUESTEDFOR
    $queryby = $env:TF_BUILD_QUEUEDBY
    
    Write-Host $requestfor
    Write-Host $queryby

    Check in this script in TFS. At the end of the build definition, add a PowerShell step to run this script file.

    Then in you build log, it will print out those values of your build variables.

    Best regards


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 07, 2017 8:34 AM
    Moderator
  • Thanks Tingting,

    I can use this script, but can you confirm why my other collections gets this values auto populated in logs without using this script.

    Does, there is any reference of this values in project which I am not aware of??

    Thanks

    Tuesday, March 07, 2017 10:36 AM
  • Hi Shyamal and Ashutosh,

    >>can you confirm why my other collections gets this values auto populated in logs without using this script

    This depends on which build steps they use, are you make sure that you're using the same build steps?

    And are you using the same build agent, did they done something on their build agent? The build agent won't show the variables by default.

    Best regards


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 08, 2017 2:14 AM
    Moderator
  • Hi Shyamal and Ashutosh,

    Is there any feedback?


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 14, 2017 8:53 AM
    Moderator