published on Friday, Mar 20, 2026 by jdamata
published on Friday, Mar 20, 2026 by jdamata
Provides a Sonarqube New Code Periods resource. This can be used to manage Sonarqube New Code Periods.
Example Usage
Example: Set the global new code period to a number of days
import * as pulumi from "@pulumi/pulumi";
import * as sonarqube from "@pulumi/sonarqube";
const codePeriod = new sonarqube.NewCodePeriods("code_period", {
type: "NUMBER_OF_DAYS",
value: "7",
});
import pulumi
import pulumi_sonarqube as sonarqube
code_period = sonarqube.NewCodePeriods("code_period",
type="NUMBER_OF_DAYS",
value="7")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/sonarqube/sonarqube"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := sonarqube.NewNewCodePeriods(ctx, "code_period", &sonarqube.NewCodePeriodsArgs{
Type: pulumi.String("NUMBER_OF_DAYS"),
Value: pulumi.String("7"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Sonarqube = Pulumi.Sonarqube;
return await Deployment.RunAsync(() =>
{
var codePeriod = new Sonarqube.NewCodePeriods("code_period", new()
{
Type = "NUMBER_OF_DAYS",
Value = "7",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.sonarqube.NewCodePeriods;
import com.pulumi.sonarqube.NewCodePeriodsArgs;
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 codePeriod = new NewCodePeriods("codePeriod", NewCodePeriodsArgs.builder()
.type("NUMBER_OF_DAYS")
.value("7")
.build());
}
}
resources:
codePeriod:
type: sonarqube:NewCodePeriods
name: code_period
properties:
type: NUMBER_OF_DAYS
value: '7'
Example: create a project and set its new code period to a reference branch
import * as pulumi from "@pulumi/pulumi";
import * as sonarqube from "@pulumi/sonarqube";
const reference = new sonarqube.Project("reference", {name: "my-project"});
const referenceNewCodePeriods = new sonarqube.NewCodePeriods("reference", {
project: reference.project,
type: "REFERENCE_BRANCH",
value: "main",
});
import pulumi
import pulumi_sonarqube as sonarqube
reference = sonarqube.Project("reference", name="my-project")
reference_new_code_periods = sonarqube.NewCodePeriods("reference",
project=reference.project,
type="REFERENCE_BRANCH",
value="main")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/sonarqube/sonarqube"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
reference, err := sonarqube.NewProject(ctx, "reference", &sonarqube.ProjectArgs{
Name: pulumi.String("my-project"),
})
if err != nil {
return err
}
_, err = sonarqube.NewNewCodePeriods(ctx, "reference", &sonarqube.NewCodePeriodsArgs{
Project: reference.Project,
Type: pulumi.String("REFERENCE_BRANCH"),
Value: pulumi.String("main"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Sonarqube = Pulumi.Sonarqube;
return await Deployment.RunAsync(() =>
{
var reference = new Sonarqube.Project("reference", new()
{
Name = "my-project",
});
var referenceNewCodePeriods = new Sonarqube.NewCodePeriods("reference", new()
{
Project = reference.Project,
Type = "REFERENCE_BRANCH",
Value = "main",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.sonarqube.Project;
import com.pulumi.sonarqube.ProjectArgs;
import com.pulumi.sonarqube.NewCodePeriods;
import com.pulumi.sonarqube.NewCodePeriodsArgs;
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 reference = new Project("reference", ProjectArgs.builder()
.name("my-project")
.build());
var referenceNewCodePeriods = new NewCodePeriods("referenceNewCodePeriods", NewCodePeriodsArgs.builder()
.project(reference.project())
.type("REFERENCE_BRANCH")
.value("main")
.build());
}
}
resources:
reference:
type: sonarqube:Project
properties:
name: my-project
referenceNewCodePeriods:
type: sonarqube:NewCodePeriods
name: reference
properties:
project: ${reference.project}
type: REFERENCE_BRANCH
value: main
Example: set a branch-specific new code period
import * as pulumi from "@pulumi/pulumi";
import * as sonarqube from "@pulumi/sonarqube";
const main = new sonarqube.Project("main", {
name: "my-project",
project: "my-project",
});
const mainBranch = new sonarqube.NewCodePeriods("main_branch", {
project: main.project,
branch: "main",
type: "PREVIOUS_VERSION",
});
import pulumi
import pulumi_sonarqube as sonarqube
main = sonarqube.Project("main",
name="my-project",
project="my-project")
main_branch = sonarqube.NewCodePeriods("main_branch",
project=main.project,
branch="main",
type="PREVIOUS_VERSION")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/sonarqube/sonarqube"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
main, err := sonarqube.NewProject(ctx, "main", &sonarqube.ProjectArgs{
Name: pulumi.String("my-project"),
Project: pulumi.String("my-project"),
})
if err != nil {
return err
}
_, err = sonarqube.NewNewCodePeriods(ctx, "main_branch", &sonarqube.NewCodePeriodsArgs{
Project: main.Project,
Branch: pulumi.String("main"),
Type: pulumi.String("PREVIOUS_VERSION"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Sonarqube = Pulumi.Sonarqube;
return await Deployment.RunAsync(() =>
{
var main = new Sonarqube.Project("main", new()
{
Name = "my-project",
Project = "my-project",
});
var mainBranch = new Sonarqube.NewCodePeriods("main_branch", new()
{
Project = main.Project,
Branch = "main",
Type = "PREVIOUS_VERSION",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.sonarqube.Project;
import com.pulumi.sonarqube.ProjectArgs;
import com.pulumi.sonarqube.NewCodePeriods;
import com.pulumi.sonarqube.NewCodePeriodsArgs;
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 main = new Project("main", ProjectArgs.builder()
.name("my-project")
.project("my-project")
.build());
var mainBranch = new NewCodePeriods("mainBranch", NewCodePeriodsArgs.builder()
.project(main.project())
.branch("main")
.type("PREVIOUS_VERSION")
.build());
}
}
resources:
main:
type: sonarqube:Project
properties:
name: my-project
project: my-project
mainBranch:
type: sonarqube:NewCodePeriods
name: main_branch
properties:
project: ${main.project}
branch: main
type: PREVIOUS_VERSION
Create NewCodePeriods Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NewCodePeriods(name: string, args: NewCodePeriodsArgs, opts?: CustomResourceOptions);@overload
def NewCodePeriods(resource_name: str,
args: NewCodePeriodsArgs,
opts: Optional[ResourceOptions] = None)
@overload
def NewCodePeriods(resource_name: str,
opts: Optional[ResourceOptions] = None,
type: Optional[str] = None,
branch: Optional[str] = None,
new_code_periods_id: Optional[str] = None,
project: Optional[str] = None,
value: Optional[str] = None)func NewNewCodePeriods(ctx *Context, name string, args NewCodePeriodsArgs, opts ...ResourceOption) (*NewCodePeriods, error)public NewCodePeriods(string name, NewCodePeriodsArgs args, CustomResourceOptions? opts = null)
public NewCodePeriods(String name, NewCodePeriodsArgs args)
public NewCodePeriods(String name, NewCodePeriodsArgs args, CustomResourceOptions options)
type: sonarqube:NewCodePeriods
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 NewCodePeriodsArgs
- 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 NewCodePeriodsArgs
- 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 NewCodePeriodsArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NewCodePeriodsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args NewCodePeriodsArgs
- 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 newCodePeriodsResource = new Sonarqube.NewCodePeriods("newCodePeriodsResource", new()
{
Type = "string",
Branch = "string",
NewCodePeriodsId = "string",
Project = "string",
Value = "string",
});
example, err := sonarqube.NewNewCodePeriods(ctx, "newCodePeriodsResource", &sonarqube.NewCodePeriodsArgs{
Type: pulumi.String("string"),
Branch: pulumi.String("string"),
NewCodePeriodsId: pulumi.String("string"),
Project: pulumi.String("string"),
Value: pulumi.String("string"),
})
var newCodePeriodsResource = new NewCodePeriods("newCodePeriodsResource", NewCodePeriodsArgs.builder()
.type("string")
.branch("string")
.newCodePeriodsId("string")
.project("string")
.value("string")
.build());
new_code_periods_resource = sonarqube.NewCodePeriods("newCodePeriodsResource",
type="string",
branch="string",
new_code_periods_id="string",
project="string",
value="string")
const newCodePeriodsResource = new sonarqube.NewCodePeriods("newCodePeriodsResource", {
type: "string",
branch: "string",
newCodePeriodsId: "string",
project: "string",
value: "string",
});
type: sonarqube:NewCodePeriods
properties:
branch: string
newCodePeriodsId: string
project: string
type: string
value: string
NewCodePeriods 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 NewCodePeriods resource accepts the following input properties:
- Type string
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- Branch string
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- New
Code stringPeriods Id - The ID of this resource.
- Project string
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- Value string
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- Type string
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- Branch string
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- New
Code stringPeriods Id - The ID of this resource.
- Project string
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- Value string
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- type String
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- branch String
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new
Code StringPeriods Id - The ID of this resource.
- project String
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- value String
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- type string
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- branch string
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new
Code stringPeriods Id - The ID of this resource.
- project string
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- value string
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- type str
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- branch str
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new_
code_ strperiods_ id - The ID of this resource.
- project str
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- value str
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- type String
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- branch String
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new
Code StringPeriods Id - The ID of this resource.
- project String
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- value String
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
Outputs
All input properties are implicitly available as output properties. Additionally, the NewCodePeriods 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 NewCodePeriods Resource
Get an existing NewCodePeriods 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?: NewCodePeriodsState, opts?: CustomResourceOptions): NewCodePeriods@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
branch: Optional[str] = None,
new_code_periods_id: Optional[str] = None,
project: Optional[str] = None,
type: Optional[str] = None,
value: Optional[str] = None) -> NewCodePeriodsfunc GetNewCodePeriods(ctx *Context, name string, id IDInput, state *NewCodePeriodsState, opts ...ResourceOption) (*NewCodePeriods, error)public static NewCodePeriods Get(string name, Input<string> id, NewCodePeriodsState? state, CustomResourceOptions? opts = null)public static NewCodePeriods get(String name, Output<String> id, NewCodePeriodsState state, CustomResourceOptions options)resources: _: type: sonarqube:NewCodePeriods get: id: ${id}- 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
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- New
Code stringPeriods Id - The ID of this resource.
- Project string
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- Type string
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- Value string
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- Branch string
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- New
Code stringPeriods Id - The ID of this resource.
- Project string
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- Type string
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- Value string
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- branch String
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new
Code StringPeriods Id - The ID of this resource.
- project String
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- type String
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- value String
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- branch string
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new
Code stringPeriods Id - The ID of this resource.
- project string
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- type string
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- value string
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- branch str
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new_
code_ strperiods_ id - The ID of this resource.
- project str
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- type str
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- value str
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
- branch String
- The name of a branch of a project for which the new code period will be configured. Changing this will force a new resource to be created. Setting this also requires setting the 'project' argument.
- new
Code StringPeriods Id - The ID of this resource.
- project String
- The key of a project for which the new code period will be configured. Changing this will force a new resource to be created.
- type String
- The kind of new code period to use. Supported values are SPECIFICANALYSIS, PREVIOUSVERSION, NUMBEROFDAYS, or REFERENCE_BRANCH.
- value String
- The desired value of the new code period. Varies based on the 'type'. For SPECIFICANALYIS, the value must be the UUID of a previous analysis. For NUMBEROFDAYS it must be a numeric string. For REFERENCEBRANCH it should be the name of branch on the project. For PREVIOUS_VERSION it must not be set.
Import
terraform
Import global new code period
$ pulumi import sonarqube:index/newCodePeriods:NewCodePeriods example newCodePeriod
Import project-specific new code period
$ pulumi import sonarqube:index/newCodePeriods:NewCodePeriods example newCodePeriod/my-project-key
Import branch-specific new code period
$ pulumi import sonarqube:index/newCodePeriods:NewCodePeriods example newCodePeriod/my-project-key/my-branch-name
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- sonarqube jdamata/terraform-provider-sonarqube
- License
- Notes
- This Pulumi package is based on the
sonarqubeTerraform Provider.
published on Friday, Mar 20, 2026 by jdamata
