Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Pruning with Azure DevOps pipelines does not seem to work #316

Open
bknapik-ah4r opened this issue Jan 13, 2023 · 4 comments
Open
Labels
bug Something isn't working known issue

Comments

@bknapik-ah4r
Copy link

bknapik-ah4r commented Jan 13, 2023

I am continuing to run into a warning regarding reference pruning in a azure devops pipeline. Specifically, I get this warning:

INFO: 2023/01/13 17:44:47 coderefs.go:199: attempting to prune old code reference data from LaunchDarkly
WARNING: 2023/01/13 17:44:47 coderefs.go:202: unable to retrieve branch list from remote, skipping code reference pruning: authentication required

A snippet from my pipeline YAML is the following:

      - checkout: self
         persistCredentials: true
      - task: Bash@3
        displayName: Set Branch Name From PR
        condition: eq(variables['Build.Reason'], 'PullRequest')
        inputs:
          targetType: inline
          script: |
            FULL_SOURCE_BRANCH_NAME=$(System.PullRequest.SourceBranch)
            SOURCE_BRANCH=${FULL_SOURCE_BRANCH_NAME##*/}
            echo "Source Branch Name: $SOURCE_BRANCH"
            echo "##vso[task.setvariable variable=sourceBranchName]$SOURCE_BRANCH"
      - task: Bash@3
        displayName: Set Branch Name from source branch
        condition: ne(variables['Build.Reason'], 'PullRequest')
        inputs:
          targetType: inline
          script: |
            FULL_SOURCE_BRANCH_NAME=$(System.PullRequest.SourceBranch)
            SOURCE_BRANCH=${FULL_SOURCE_BRANCH_NAME##*/}
            echo "Source Branch Name: $(Build.SourceBranchName)"
            echo "##vso[task.setvariable variable=sourceBranchName]$(Build.SourceBranchName)"
      - task: Bash@3
        displayName: Run Launch Darkly Find Code Refs
        inputs:
          targetType: inline
          script: |
            curl -L https://github.com/launchdarkly/ld-find-code-refs/releases/download/v2.8.0/ld-find-code-refs_2.8.0_linux_amd64.tar.gz | tar xvz -C $(Agent.TempDirectory)
            $(Agent.TempDirectory)/ld-find-code-refs --debug --dir=. --accessToken=XXX --projKey=${{ parameters.launchDarklyProjectKey }} --repoName=$(Build.Repository.Name) --branch=$(sourceBranchName)

The pipeline in essence, checks out the code, figures out the branch name, then runs ld-find-code-refs on the current directory. From what I can gather it seems like ld-find-code-refs does not integrate with the git authorization in azure pipelines.

I am setting persistCredentials which gives the pipeline access to the entire repository. From the documentation:
"Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it." We are able use persist credentials in other parts of our pipelines successfully to push tags for example.

To try and debug this process, I was looking in the code and it seems like it is looking for a .git folder. I have confirmed that the .git folder exists when running the pipeline. The .git folder has the following files/subfolders:

FETCH_HEAD
HEAD
branches
config
description
hooks
index
info
logs
objects
refs

Is there a way to have reference pruning work in azure pipelines? If not, is there some a way we can request it to be added in a future release?

Thanks

@jazanne
Copy link
Contributor

jazanne commented Jan 23, 2023

Hi, thank you for submitting this issue. This is a known issue with branch pruning that was introduced in v2.6.1. Sorry for the inconvenience.

@jazanne jazanne added the bug Something isn't working label Jan 23, 2023
@bknapik-ah4r
Copy link
Author

Thanks for letting me know. I changed my pipeline to 2.6.0 and that seems to work. I will continue to track this ticket and will update my pipelines to the latest when it is resolved.

@bknapik-ah4r
Copy link
Author

Is there any plan to address this? I am continuing to run 2.6.0 due to the bug introduced in 2.6.1 that broke this functionality in Azure Devops.

I am looking to upgrade if possible, as I was hoping it may help with my degradation of performance in azure pipelines. See LaunchDarkly support ticket 62946 for details.

@jazanne
Copy link
Contributor

jazanne commented Feb 21, 2024

@bknapik-ah4r at this time we don't have a planned fix for the pruning error, however you can run newer versions of the CLI with --prune=false to skip the failing step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working known issue
Projects
None yet
Development

No branches or pull requests

2 participants