1. Packages
  2. Azure DevOps Provider
  3. API Docs
  4. getGitRepositoryFile
Azure DevOps v3.9.0 published on Tuesday, Apr 22, 2025 by Pulumi

azuredevops.getGitRepositoryFile

Explore with Pulumi AI

azuredevops logo
Azure DevOps v3.9.0 published on Tuesday, Apr 22, 2025 by Pulumi

    Use this data source to get an existing Git Repository File.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const example = azuredevops.getProject({
        name: "Example Project",
    });
    // Load a specific Git repository by name
    const exampleGetGitRepository = example.then(example => azuredevops.getGitRepository({
        projectId: example.id,
        name: "Example Repository",
    }));
    const exampleGetGitRepositoryFile = exampleGetGitRepository.then(exampleGetGitRepository => azuredevops.getGitRepositoryFile({
        repositoryId: exampleGetGitRepository.id,
        branch: "refs/heads/main",
        file: "MyFile.txt",
    }));
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example = azuredevops.get_project(name="Example Project")
    # Load a specific Git repository by name
    example_get_git_repository = azuredevops.get_git_repository(project_id=example.id,
        name="Example Repository")
    example_get_git_repository_file = azuredevops.get_git_repository_file(repository_id=example_get_git_repository.id,
        branch="refs/heads/main",
        file="MyFile.txt")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v3/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := azuredevops.LookupProject(ctx, &azuredevops.LookupProjectArgs{
    			Name: pulumi.StringRef("Example Project"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Load a specific Git repository by name
    		exampleGetGitRepository, err := azuredevops.GetGitRepository(ctx, &azuredevops.GetGitRepositoryArgs{
    			ProjectId: example.Id,
    			Name:      "Example Repository",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.LookupGitRepositoryFile(ctx, &azuredevops.LookupGitRepositoryFileArgs{
    			RepositoryId: exampleGetGitRepository.Id,
    			Branch:       pulumi.StringRef("refs/heads/main"),
    			File:         "MyFile.txt",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var example = AzureDevOps.GetProject.Invoke(new()
        {
            Name = "Example Project",
        });
    
        // Load a specific Git repository by name
        var exampleGetGitRepository = AzureDevOps.GetGitRepository.Invoke(new()
        {
            ProjectId = example.Apply(getProjectResult => getProjectResult.Id),
            Name = "Example Repository",
        });
    
        var exampleGetGitRepositoryFile = AzureDevOps.GetGitRepositoryFile.Invoke(new()
        {
            RepositoryId = exampleGetGitRepository.Apply(getGitRepositoryResult => getGitRepositoryResult.Id),
            Branch = "refs/heads/main",
            File = "MyFile.txt",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.AzuredevopsFunctions;
    import com.pulumi.azuredevops.inputs.GetProjectArgs;
    import com.pulumi.azuredevops.inputs.GetGitRepositoryArgs;
    import com.pulumi.azuredevops.inputs.GetGitRepositoryFileArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = AzuredevopsFunctions.getProject(GetProjectArgs.builder()
                .name("Example Project")
                .build());
    
            // Load a specific Git repository by name
            final var exampleGetGitRepository = AzuredevopsFunctions.getGitRepository(GetGitRepositoryArgs.builder()
                .projectId(example.id())
                .name("Example Repository")
                .build());
    
            final var exampleGetGitRepositoryFile = AzuredevopsFunctions.getGitRepositoryFile(GetGitRepositoryFileArgs.builder()
                .repositoryId(exampleGetGitRepository.id())
                .branch("refs/heads/main")
                .file("MyFile.txt")
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: azuredevops:getProject
          arguments:
            name: Example Project
      # Load a specific Git repository by name
      exampleGetGitRepository:
        fn::invoke:
          function: azuredevops:getGitRepository
          arguments:
            projectId: ${example.id}
            name: Example Repository
      exampleGetGitRepositoryFile:
        fn::invoke:
          function: azuredevops:getGitRepositoryFile
          arguments:
            repositoryId: ${exampleGetGitRepository.id}
            branch: refs/heads/main
            file: MyFile.txt
    

    Using getGitRepositoryFile

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getGitRepositoryFile(args: GetGitRepositoryFileArgs, opts?: InvokeOptions): Promise<GetGitRepositoryFileResult>
    function getGitRepositoryFileOutput(args: GetGitRepositoryFileOutputArgs, opts?: InvokeOptions): Output<GetGitRepositoryFileResult>
    def get_git_repository_file(branch: Optional[str] = None,
                                file: Optional[str] = None,
                                repository_id: Optional[str] = None,
                                tag: Optional[str] = None,
                                opts: Optional[InvokeOptions] = None) -> GetGitRepositoryFileResult
    def get_git_repository_file_output(branch: Optional[pulumi.Input[str]] = None,
                                file: Optional[pulumi.Input[str]] = None,
                                repository_id: Optional[pulumi.Input[str]] = None,
                                tag: Optional[pulumi.Input[str]] = None,
                                opts: Optional[InvokeOptions] = None) -> Output[GetGitRepositoryFileResult]
    func LookupGitRepositoryFile(ctx *Context, args *LookupGitRepositoryFileArgs, opts ...InvokeOption) (*LookupGitRepositoryFileResult, error)
    func LookupGitRepositoryFileOutput(ctx *Context, args *LookupGitRepositoryFileOutputArgs, opts ...InvokeOption) LookupGitRepositoryFileResultOutput

    > Note: This function is named LookupGitRepositoryFile in the Go SDK.

    public static class GetGitRepositoryFile 
    {
        public static Task<GetGitRepositoryFileResult> InvokeAsync(GetGitRepositoryFileArgs args, InvokeOptions? opts = null)
        public static Output<GetGitRepositoryFileResult> Invoke(GetGitRepositoryFileInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetGitRepositoryFileResult> getGitRepositoryFile(GetGitRepositoryFileArgs args, InvokeOptions options)
    public static Output<GetGitRepositoryFileResult> getGitRepositoryFile(GetGitRepositoryFileArgs args, InvokeOptions options)
    
    fn::invoke:
      function: azuredevops:index/getGitRepositoryFile:getGitRepositoryFile
      arguments:
        # arguments dictionary

    The following arguments are supported:

    File string
    The path of the file to get.
    RepositoryId string
    The ID of the Git repository.
    Branch string
    The git branch to use. Conflicts with tag; one or the other must be specified.
    Tag string
    The tag to use.Conflicts with branch; one or the other must be specified.
    File string
    The path of the file to get.
    RepositoryId string
    The ID of the Git repository.
    Branch string
    The git branch to use. Conflicts with tag; one or the other must be specified.
    Tag string
    The tag to use.Conflicts with branch; one or the other must be specified.
    file String
    The path of the file to get.
    repositoryId String
    The ID of the Git repository.
    branch String
    The git branch to use. Conflicts with tag; one or the other must be specified.
    tag String
    The tag to use.Conflicts with branch; one or the other must be specified.
    file string
    The path of the file to get.
    repositoryId string
    The ID of the Git repository.
    branch string
    The git branch to use. Conflicts with tag; one or the other must be specified.
    tag string
    The tag to use.Conflicts with branch; one or the other must be specified.
    file str
    The path of the file to get.
    repository_id str
    The ID of the Git repository.
    branch str
    The git branch to use. Conflicts with tag; one or the other must be specified.
    tag str
    The tag to use.Conflicts with branch; one or the other must be specified.
    file String
    The path of the file to get.
    repositoryId String
    The ID of the Git repository.
    branch String
    The git branch to use. Conflicts with tag; one or the other must be specified.
    tag String
    The tag to use.Conflicts with branch; one or the other must be specified.

    getGitRepositoryFile Result

    The following output properties are available:

    Content string
    The file content.
    File string
    Id string
    The provider-assigned unique ID for this managed resource.
    LastCommitMessage string
    The commit message for the file.
    RepositoryId string
    Branch string
    Tag string
    Content string
    The file content.
    File string
    Id string
    The provider-assigned unique ID for this managed resource.
    LastCommitMessage string
    The commit message for the file.
    RepositoryId string
    Branch string
    Tag string
    content String
    The file content.
    file String
    id String
    The provider-assigned unique ID for this managed resource.
    lastCommitMessage String
    The commit message for the file.
    repositoryId String
    branch String
    tag String
    content string
    The file content.
    file string
    id string
    The provider-assigned unique ID for this managed resource.
    lastCommitMessage string
    The commit message for the file.
    repositoryId string
    branch string
    tag string
    content str
    The file content.
    file str
    id str
    The provider-assigned unique ID for this managed resource.
    last_commit_message str
    The commit message for the file.
    repository_id str
    branch str
    tag str
    content String
    The file content.
    file String
    id String
    The provider-assigned unique ID for this managed resource.
    lastCommitMessage String
    The commit message for the file.
    repositoryId String
    branch String
    tag String

    Package Details

    Repository
    Azure DevOps pulumi/pulumi-azuredevops
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azuredevops Terraform Provider.
    azuredevops logo
    Azure DevOps v3.9.0 published on Tuesday, Apr 22, 2025 by Pulumi