azuredevops.GitRepositoryFile
Explore with Pulumi AI
Manage files within an Azure DevOps Git repository.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azuredevops from "@pulumi/azuredevops";
const example = new azuredevops.Project("example", {
name: "Example Project",
visibility: "private",
versionControl: "Git",
workItemTemplate: "Agile",
});
const exampleGit = new azuredevops.Git("example", {
projectId: example.id,
name: "Example Git Repository",
initialization: {
initType: "Clean",
},
});
const exampleGitRepositoryFile = new azuredevops.GitRepositoryFile("example", {
repositoryId: exampleGit.id,
file: ".gitignore",
content: "**/*.tfstate",
branch: "refs/heads/master",
commitMessage: "First commit",
overwriteOnCreate: false,
});
import pulumi
import pulumi_azuredevops as azuredevops
example = azuredevops.Project("example",
name="Example Project",
visibility="private",
version_control="Git",
work_item_template="Agile")
example_git = azuredevops.Git("example",
project_id=example.id,
name="Example Git Repository",
initialization={
"init_type": "Clean",
})
example_git_repository_file = azuredevops.GitRepositoryFile("example",
repository_id=example_git.id,
file=".gitignore",
content="**/*.tfstate",
branch="refs/heads/master",
commit_message="First commit",
overwrite_on_create=False)
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.NewProject(ctx, "example", &azuredevops.ProjectArgs{
Name: pulumi.String("Example Project"),
Visibility: pulumi.String("private"),
VersionControl: pulumi.String("Git"),
WorkItemTemplate: pulumi.String("Agile"),
})
if err != nil {
return err
}
exampleGit, err := azuredevops.NewGit(ctx, "example", &azuredevops.GitArgs{
ProjectId: example.ID(),
Name: pulumi.String("Example Git Repository"),
Initialization: &azuredevops.GitInitializationArgs{
InitType: pulumi.String("Clean"),
},
})
if err != nil {
return err
}
_, err = azuredevops.NewGitRepositoryFile(ctx, "example", &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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureDevOps = Pulumi.AzureDevOps;
return await Deployment.RunAsync(() =>
{
var example = new AzureDevOps.Project("example", new()
{
Name = "Example Project",
Visibility = "private",
VersionControl = "Git",
WorkItemTemplate = "Agile",
});
var exampleGit = new AzureDevOps.Git("example", new()
{
ProjectId = example.Id,
Name = "Example Git Repository",
Initialization = new AzureDevOps.Inputs.GitInitializationArgs
{
InitType = "Clean",
},
});
var exampleGitRepositoryFile = new AzureDevOps.GitRepositoryFile("example", new()
{
RepositoryId = exampleGit.Id,
File = ".gitignore",
Content = "**/*.tfstate",
Branch = "refs/heads/master",
CommitMessage = "First commit",
OverwriteOnCreate = false,
});
});
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 example = new Project("example", ProjectArgs.builder()
.name("Example Project")
.visibility("private")
.versionControl("Git")
.workItemTemplate("Agile")
.build());
var exampleGit = new Git("exampleGit", GitArgs.builder()
.projectId(example.id())
.name("Example Git Repository")
.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());
}
}
resources:
example:
type: azuredevops:Project
properties:
name: Example Project
visibility: private
versionControl: Git
workItemTemplate: Agile
exampleGit:
type: azuredevops:Git
name: example
properties:
projectId: ${example.id}
name: Example Git Repository
initialization:
initType: Clean
exampleGitRepositoryFile:
type: azuredevops:GitRepositoryFile
name: example
properties:
repositoryId: ${exampleGit.id}
file: .gitignore
content: '**/*.tfstate'
branch: refs/heads/master
commitMessage: First commit
overwriteOnCreate: false
Relevant Links
Create GitRepositoryFile Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new GitRepositoryFile(name: string, args: GitRepositoryFileArgs, opts?: CustomResourceOptions);
@overload
def GitRepositoryFile(resource_name: str,
args: GitRepositoryFileArgs,
opts: Optional[ResourceOptions] = None)
@overload
def GitRepositoryFile(resource_name: str,
opts: Optional[ResourceOptions] = None,
content: Optional[str] = None,
file: Optional[str] = None,
repository_id: Optional[str] = None,
branch: Optional[str] = None,
commit_message: Optional[str] = None,
overwrite_on_create: Optional[bool] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var gitRepositoryFileResource = new AzureDevOps.GitRepositoryFile("gitRepositoryFileResource", new()
{
Content = "string",
File = "string",
RepositoryId = "string",
Branch = "string",
CommitMessage = "string",
OverwriteOnCreate = false,
});
example, err := azuredevops.NewGitRepositoryFile(ctx, "gitRepositoryFileResource", &azuredevops.GitRepositoryFileArgs{
Content: pulumi.String("string"),
File: pulumi.String("string"),
RepositoryId: pulumi.String("string"),
Branch: pulumi.String("string"),
CommitMessage: pulumi.String("string"),
OverwriteOnCreate: pulumi.Bool(false),
})
var gitRepositoryFileResource = new GitRepositoryFile("gitRepositoryFileResource", GitRepositoryFileArgs.builder()
.content("string")
.file("string")
.repositoryId("string")
.branch("string")
.commitMessage("string")
.overwriteOnCreate(false)
.build());
git_repository_file_resource = azuredevops.GitRepositoryFile("gitRepositoryFileResource",
content="string",
file="string",
repository_id="string",
branch="string",
commit_message="string",
overwrite_on_create=False)
const gitRepositoryFileResource = new azuredevops.GitRepositoryFile("gitRepositoryFileResource", {
content: "string",
file: "string",
repositoryId: "string",
branch: "string",
commitMessage: "string",
overwriteOnCreate: false,
});
type: azuredevops:GitRepositoryFile
properties:
branch: string
commitMessage: string
content: string
file: string
overwriteOnCreate: false
repositoryId: string
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The GitRepositoryFile resource accepts the following input properties:
- Content string
- The file content.
- File string
- The path of the file to manage.
- Repository
Id 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. - Commit
Message string - Commit message when adding or updating the managed file.
- Overwrite
On boolCreate - Enable overwriting existing files (defaults to
false
).
- Content string
- The file content.
- File string
- The path of the file to manage.
- Repository
Id 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. - Commit
Message string - Commit message when adding or updating the managed file.
- Overwrite
On boolCreate - Enable overwriting existing files (defaults to
false
).
- content String
- The file content.
- file String
- The path of the file to manage.
- repository
Id 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. - commit
Message String - Commit message when adding or updating the managed file.
- overwrite
On BooleanCreate - Enable overwriting existing files (defaults to
false
).
- content string
- The file content.
- file string
- The path of the file to manage.
- repository
Id 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. - commit
Message string - Commit message when adding or updating the managed file.
- overwrite
On booleanCreate - 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_ boolcreate - Enable overwriting existing files (defaults to
false
).
- content String
- The file content.
- file String
- The path of the file to manage.
- repository
Id 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. - commit
Message String - Commit message when adding or updating the managed file.
- overwrite
On BooleanCreate - 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.
- 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. - Commit
Message string - Commit message when adding or updating the managed file.
- Content string
- The file content.
- File string
- The path of the file to manage.
- Overwrite
On boolCreate - Enable overwriting existing files (defaults to
false
). - Repository
Id 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. - Commit
Message string - Commit message when adding or updating the managed file.
- Content string
- The file content.
- File string
- The path of the file to manage.
- Overwrite
On boolCreate - Enable overwriting existing files (defaults to
false
). - Repository
Id 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. - commit
Message String - Commit message when adding or updating the managed file.
- content String
- The file content.
- file String
- The path of the file to manage.
- overwrite
On BooleanCreate - Enable overwriting existing files (defaults to
false
). - repository
Id 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. - commit
Message string - Commit message when adding or updating the managed file.
- content string
- The file content.
- file string
- The path of the file to manage.
- overwrite
On booleanCreate - Enable overwriting existing files (defaults to
false
). - repository
Id 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_ boolcreate - 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. - commit
Message String - Commit message when adding or updating the managed file.
- content String
- The file content.
- file String
- The path of the file to manage.
- overwrite
On BooleanCreate - Enable overwriting existing files (defaults to
false
). - repository
Id String - The ID of the Git repository.
Import
Repository files can be imported using a combination of the repository 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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure DevOps pulumi/pulumi-azuredevops
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azuredevops
Terraform Provider.