azuredevops logo
Azure DevOps v2.7.0, Mar 27 23

azuredevops.GitRepositoryFile

Explore with Pulumi AI

Manage files within an Azure DevOps Git repository.

Example Usage

using System.Collections.Generic;
using Pulumi;
using AzureDevOps = Pulumi.AzureDevOps;

return await Deployment.RunAsync(() => 
{
    var exampleProject = new AzureDevOps.Project("exampleProject", new()
    {
        Visibility = "private",
        VersionControl = "Git",
        WorkItemTemplate = "Agile",
    });

    var exampleGit = new AzureDevOps.Git("exampleGit", new()
    {
        ProjectId = exampleProject.Id,
        Initialization = new AzureDevOps.Inputs.GitInitializationArgs
        {
            InitType = "Clean",
        },
    });

    var exampleGitRepositoryFile = new AzureDevOps.GitRepositoryFile("exampleGitRepositoryFile", new()
    {
        RepositoryId = exampleGit.Id,
        File = ".gitignore",
        Content = "**/*.tfstate",
        Branch = "refs/heads/master",
        CommitMessage = "First commit",
        OverwriteOnCreate = false,
    });

});
package main

import (
	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", &azuredevops.ProjectArgs{
			Visibility:       pulumi.String("private"),
			VersionControl:   pulumi.String("Git"),
			WorkItemTemplate: pulumi.String("Agile"),
		})
		if err != nil {
			return err
		}
		exampleGit, err := azuredevops.NewGit(ctx, "exampleGit", &azuredevops.GitArgs{
			ProjectId: exampleProject.ID(),
			Initialization: &azuredevops.GitInitializationArgs{
				InitType: pulumi.String("Clean"),
			},
		})
		if err != nil {
			return err
		}
		_, err = azuredevops.NewGitRepositoryFile(ctx, "exampleGitRepositoryFile", &azuredevops.GitRepositoryFileArgs{
			RepositoryId:      exampleGit.ID(),
			File:              pulumi.String(".gitignore"),
			Content:           pulumi.String("**/*.tfstate"),
			Branch:            pulumi.String("refs/heads/master"),
			CommitMessage:     pulumi.String("First commit"),
			OverwriteOnCreate: pulumi.Bool(false),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuredevops.Project;
import com.pulumi.azuredevops.ProjectArgs;
import com.pulumi.azuredevops.Git;
import com.pulumi.azuredevops.GitArgs;
import com.pulumi.azuredevops.inputs.GitInitializationArgs;
import com.pulumi.azuredevops.GitRepositoryFile;
import com.pulumi.azuredevops.GitRepositoryFileArgs;
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) {
        var exampleProject = new Project("exampleProject", ProjectArgs.builder()        
            .visibility("private")
            .versionControl("Git")
            .workItemTemplate("Agile")
            .build());

        var exampleGit = new Git("exampleGit", GitArgs.builder()        
            .projectId(exampleProject.id())
            .initialization(GitInitializationArgs.builder()
                .initType("Clean")
                .build())
            .build());

        var exampleGitRepositoryFile = new GitRepositoryFile("exampleGitRepositoryFile", GitRepositoryFileArgs.builder()        
            .repositoryId(exampleGit.id())
            .file(".gitignore")
            .content("**/*.tfstate")
            .branch("refs/heads/master")
            .commitMessage("First commit")
            .overwriteOnCreate(false)
            .build());

    }
}
import pulumi
import pulumi_azuredevops as azuredevops

example_project = azuredevops.Project("exampleProject",
    visibility="private",
    version_control="Git",
    work_item_template="Agile")
example_git = azuredevops.Git("exampleGit",
    project_id=example_project.id,
    initialization=azuredevops.GitInitializationArgs(
        init_type="Clean",
    ))
example_git_repository_file = azuredevops.GitRepositoryFile("exampleGitRepositoryFile",
    repository_id=example_git.id,
    file=".gitignore",
    content="**/*.tfstate",
    branch="refs/heads/master",
    commit_message="First commit",
    overwrite_on_create=False)
import * as pulumi from "@pulumi/pulumi";
import * as azuredevops from "@pulumi/azuredevops";

const exampleProject = new azuredevops.Project("exampleProject", {
    visibility: "private",
    versionControl: "Git",
    workItemTemplate: "Agile",
});
const exampleGit = new azuredevops.Git("exampleGit", {
    projectId: exampleProject.id,
    initialization: {
        initType: "Clean",
    },
});
const exampleGitRepositoryFile = new azuredevops.GitRepositoryFile("exampleGitRepositoryFile", {
    repositoryId: exampleGit.id,
    file: ".gitignore",
    content: "**/*.tfstate",
    branch: "refs/heads/master",
    commitMessage: "First commit",
    overwriteOnCreate: false,
});
resources:
  exampleProject:
    type: azuredevops:Project
    properties:
      visibility: private
      versionControl: Git
      workItemTemplate: Agile
  exampleGit:
    type: azuredevops:Git
    properties:
      projectId: ${exampleProject.id}
      initialization:
        initType: Clean
  exampleGitRepositoryFile:
    type: azuredevops:GitRepositoryFile
    properties:
      repositoryId: ${exampleGit.id}
      file: .gitignore
      content: '**/*.tfstate'
      branch: refs/heads/master
      commitMessage: First commit
      overwriteOnCreate: false

Create GitRepositoryFile Resource

new GitRepositoryFile(name: string, args: GitRepositoryFileArgs, opts?: CustomResourceOptions);
@overload
def GitRepositoryFile(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      branch: Optional[str] = None,
                      commit_message: Optional[str] = None,
                      content: Optional[str] = None,
                      file: Optional[str] = None,
                      overwrite_on_create: Optional[bool] = None,
                      repository_id: Optional[str] = None)
@overload
def GitRepositoryFile(resource_name: str,
                      args: GitRepositoryFileArgs,
                      opts: Optional[ResourceOptions] = None)
func NewGitRepositoryFile(ctx *Context, name string, args GitRepositoryFileArgs, opts ...ResourceOption) (*GitRepositoryFile, error)
public GitRepositoryFile(string name, GitRepositoryFileArgs args, CustomResourceOptions? opts = null)
public GitRepositoryFile(String name, GitRepositoryFileArgs args)
public GitRepositoryFile(String name, GitRepositoryFileArgs args, CustomResourceOptions options)
type: azuredevops:GitRepositoryFile
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args GitRepositoryFileArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args GitRepositoryFileArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args GitRepositoryFileArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args GitRepositoryFileArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args GitRepositoryFileArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

GitRepositoryFile Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The GitRepositoryFile resource accepts the following input properties:

Content string

The file content.

File string

The path of the file to manage.

RepositoryId string

The ID of the Git repository.

Branch string

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

CommitMessage string

Commit message when adding or updating the managed file.

OverwriteOnCreate bool

Enable overwriting existing files (defaults to false).

Content string

The file content.

File string

The path of the file to manage.

RepositoryId string

The ID of the Git repository.

Branch string

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

CommitMessage string

Commit message when adding or updating the managed file.

OverwriteOnCreate bool

Enable overwriting existing files (defaults to false).

content String

The file content.

file String

The path of the file to manage.

repositoryId String

The ID of the Git repository.

branch String

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commitMessage String

Commit message when adding or updating the managed file.

overwriteOnCreate Boolean

Enable overwriting existing files (defaults to false).

content string

The file content.

file string

The path of the file to manage.

repositoryId string

The ID of the Git repository.

branch string

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commitMessage string

Commit message when adding or updating the managed file.

overwriteOnCreate boolean

Enable overwriting existing files (defaults to false).

content str

The file content.

file str

The path of the file to manage.

repository_id str

The ID of the Git repository.

branch str

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commit_message str

Commit message when adding or updating the managed file.

overwrite_on_create bool

Enable overwriting existing files (defaults to false).

content String

The file content.

file String

The path of the file to manage.

repositoryId String

The ID of the Git repository.

branch String

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commitMessage String

Commit message when adding or updating the managed file.

overwriteOnCreate Boolean

Enable overwriting existing files (defaults to false).

Outputs

All input properties are implicitly available as output properties. Additionally, the GitRepositoryFile resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing GitRepositoryFile Resource

Get an existing GitRepositoryFile resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: GitRepositoryFileState, opts?: CustomResourceOptions): GitRepositoryFile
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        branch: Optional[str] = None,
        commit_message: Optional[str] = None,
        content: Optional[str] = None,
        file: Optional[str] = None,
        overwrite_on_create: Optional[bool] = None,
        repository_id: Optional[str] = None) -> GitRepositoryFile
func GetGitRepositoryFile(ctx *Context, name string, id IDInput, state *GitRepositoryFileState, opts ...ResourceOption) (*GitRepositoryFile, error)
public static GitRepositoryFile Get(string name, Input<string> id, GitRepositoryFileState? state, CustomResourceOptions? opts = null)
public static GitRepositoryFile get(String name, Output<String> id, GitRepositoryFileState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Branch string

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

CommitMessage string

Commit message when adding or updating the managed file.

Content string

The file content.

File string

The path of the file to manage.

OverwriteOnCreate bool

Enable overwriting existing files (defaults to false).

RepositoryId string

The ID of the Git repository.

Branch string

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

CommitMessage string

Commit message when adding or updating the managed file.

Content string

The file content.

File string

The path of the file to manage.

OverwriteOnCreate bool

Enable overwriting existing files (defaults to false).

RepositoryId string

The ID of the Git repository.

branch String

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commitMessage String

Commit message when adding or updating the managed file.

content String

The file content.

file String

The path of the file to manage.

overwriteOnCreate Boolean

Enable overwriting existing files (defaults to false).

repositoryId String

The ID of the Git repository.

branch string

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commitMessage string

Commit message when adding or updating the managed file.

content string

The file content.

file string

The path of the file to manage.

overwriteOnCreate boolean

Enable overwriting existing files (defaults to false).

repositoryId string

The ID of the Git repository.

branch str

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commit_message str

Commit message when adding or updating the managed file.

content str

The file content.

file str

The path of the file to manage.

overwrite_on_create bool

Enable overwriting existing files (defaults to false).

repository_id str

The ID of the Git repository.

branch String

Git branch (defaults to refs/heads/master). The branch must already exist, it will not be created if it does not already exist.

commitMessage String

Commit message when adding or updating the managed file.

content String

The file content.

file String

The path of the file to manage.

overwriteOnCreate Boolean

Enable overwriting existing files (defaults to false).

repositoryId String

The ID of the Git repository.

Import

Repository files can be imported using a combination of the repositroy ID and file, e.g.

 $ pulumi import azuredevops:index/gitRepositoryFile:GitRepositoryFile example 00000000-0000-0000-0000-000000000000/.gitignore

To import a file from a branch other than master, append : and the branch name, e.g.

 $ pulumi import azuredevops:index/gitRepositoryFile:GitRepositoryFile example 00000000-0000-0000-0000-000000000000/.gitignore:refs/heads/master

Package Details

Repository
Azure DevOps pulumi/pulumi-azuredevops
License
Apache-2.0
Notes

This Pulumi package is based on the azuredevops Terraform Provider.