1. Packages
  2. Sonarqube Provider
  3. API Docs
  4. Qualitygate
sonarqube 0.16.14 published on Monday, Apr 14, 2025 by jdamata

sonarqube.Qualitygate

Explore with Pulumi AI

sonarqube logo
sonarqube 0.16.14 published on Monday, Apr 14, 2025 by jdamata

    Provides a Sonarqube Quality Gate resource. This can be used to create and manage Sonarqube Quality Gates and their Conditions.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as sonarqube from "@pulumi/sonarqube";
    
    const main = new sonarqube.Qualitygate("main", {
        conditions: [
            {
                metric: "new_coverage",
                op: "LT",
                threshold: "50",
            },
            {
                metric: "vulnerabilities",
                op: "GT",
                threshold: "10",
            },
        ],
        isDefault: true,
    });
    
    import pulumi
    import pulumi_sonarqube as sonarqube
    
    main = sonarqube.Qualitygate("main",
        conditions=[
            {
                "metric": "new_coverage",
                "op": "LT",
                "threshold": "50",
            },
            {
                "metric": "vulnerabilities",
                "op": "GT",
                "threshold": "10",
            },
        ],
        is_default=True)
    
    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.NewQualitygate(ctx, "main", &sonarqube.QualitygateArgs{
    			Conditions: sonarqube.QualitygateConditionArray{
    				&sonarqube.QualitygateConditionArgs{
    					Metric:    pulumi.String("new_coverage"),
    					Op:        pulumi.String("LT"),
    					Threshold: pulumi.String("50"),
    				},
    				&sonarqube.QualitygateConditionArgs{
    					Metric:    pulumi.String("vulnerabilities"),
    					Op:        pulumi.String("GT"),
    					Threshold: pulumi.String("10"),
    				},
    			},
    			IsDefault: pulumi.Bool(true),
    		})
    		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.Qualitygate("main", new()
        {
            Conditions = new[]
            {
                new Sonarqube.Inputs.QualitygateConditionArgs
                {
                    Metric = "new_coverage",
                    Op = "LT",
                    Threshold = "50",
                },
                new Sonarqube.Inputs.QualitygateConditionArgs
                {
                    Metric = "vulnerabilities",
                    Op = "GT",
                    Threshold = "10",
                },
            },
            IsDefault = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.sonarqube.Qualitygate;
    import com.pulumi.sonarqube.QualitygateArgs;
    import com.pulumi.sonarqube.inputs.QualitygateConditionArgs;
    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 Qualitygate("main", QualitygateArgs.builder()
                .conditions(            
                    QualitygateConditionArgs.builder()
                        .metric("new_coverage")
                        .op("LT")
                        .threshold("50")
                        .build(),
                    QualitygateConditionArgs.builder()
                        .metric("vulnerabilities")
                        .op("GT")
                        .threshold("10")
                        .build())
                .isDefault(true)
                .build());
    
        }
    }
    
    resources:
      main:
        type: sonarqube:Qualitygate
        properties:
          conditions:
            - metric: new_coverage
              op: LT
              threshold: '50'
            - metric: vulnerabilities
              op: GT
              threshold: '10'
          isDefault: true
    

    Disclaimer: Operator Requirement for Grade Rating Conditions

    When working with grade rating conditions, (A-D), it is important to note that the “GT” (greater than) operator must be used for the op field. This is due to SonarQube’s API design. More information can be found in this issue.

    For example, if you are using a grade rating metric such as new_reliability_rating, where A represents the highest rating and subsequent letters represent lower ratings, you need to supply the op field with “GT” via the provider. Using “LT” will return an error from SonarQube’s API:

    import * as pulumi from "@pulumi/pulumi";
    
    import pulumi
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    
    return await Deployment.RunAsync(() => 
    {
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    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) {
        }
    }
    
    {}
    

    Create Qualitygate Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Qualitygate(name: string, args?: QualitygateArgs, opts?: CustomResourceOptions);
    @overload
    def Qualitygate(resource_name: str,
                    args: Optional[QualitygateArgs] = None,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def Qualitygate(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    conditions: Optional[Sequence[QualitygateConditionArgs]] = None,
                    copy_from: Optional[str] = None,
                    is_default: Optional[bool] = None,
                    name: Optional[str] = None,
                    qualitygate_id: Optional[str] = None)
    func NewQualitygate(ctx *Context, name string, args *QualitygateArgs, opts ...ResourceOption) (*Qualitygate, error)
    public Qualitygate(string name, QualitygateArgs? args = null, CustomResourceOptions? opts = null)
    public Qualitygate(String name, QualitygateArgs args)
    public Qualitygate(String name, QualitygateArgs args, CustomResourceOptions options)
    
    type: sonarqube:Qualitygate
    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 QualitygateArgs
    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 QualitygateArgs
    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 QualitygateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args QualitygateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args QualitygateArgs
    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 qualitygateResource = new Sonarqube.Qualitygate("qualitygateResource", new()
    {
        Conditions = new[]
        {
            new Sonarqube.Inputs.QualitygateConditionArgs
            {
                Metric = "string",
                Op = "string",
                Threshold = "string",
                Id = "string",
            },
        },
        CopyFrom = "string",
        IsDefault = false,
        Name = "string",
        QualitygateId = "string",
    });
    
    example, err := sonarqube.NewQualitygate(ctx, "qualitygateResource", &sonarqube.QualitygateArgs{
    	Conditions: sonarqube.QualitygateConditionArray{
    		&sonarqube.QualitygateConditionArgs{
    			Metric:    pulumi.String("string"),
    			Op:        pulumi.String("string"),
    			Threshold: pulumi.String("string"),
    			Id:        pulumi.String("string"),
    		},
    	},
    	CopyFrom:      pulumi.String("string"),
    	IsDefault:     pulumi.Bool(false),
    	Name:          pulumi.String("string"),
    	QualitygateId: pulumi.String("string"),
    })
    
    var qualitygateResource = new Qualitygate("qualitygateResource", QualitygateArgs.builder()
        .conditions(QualitygateConditionArgs.builder()
            .metric("string")
            .op("string")
            .threshold("string")
            .id("string")
            .build())
        .copyFrom("string")
        .isDefault(false)
        .name("string")
        .qualitygateId("string")
        .build());
    
    qualitygate_resource = sonarqube.Qualitygate("qualitygateResource",
        conditions=[{
            "metric": "string",
            "op": "string",
            "threshold": "string",
            "id": "string",
        }],
        copy_from="string",
        is_default=False,
        name="string",
        qualitygate_id="string")
    
    const qualitygateResource = new sonarqube.Qualitygate("qualitygateResource", {
        conditions: [{
            metric: "string",
            op: "string",
            threshold: "string",
            id: "string",
        }],
        copyFrom: "string",
        isDefault: false,
        name: "string",
        qualitygateId: "string",
    });
    
    type: sonarqube:Qualitygate
    properties:
        conditions:
            - id: string
              metric: string
              op: string
              threshold: string
        copyFrom: string
        isDefault: false
        name: string
        qualitygateId: string
    

    Qualitygate 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 Qualitygate resource accepts the following input properties:

    Conditions List<QualitygateCondition>
    A list of conditions that the gate uses.
    CopyFrom string
    Name of an existing Quality Gate to copy from.
    IsDefault bool
    When set to true this Quality Gate is set as default.
    Name string
    The name of the Quality Gate to create. Maximum length 100.
    QualitygateId string
    The ID of this resource.
    Conditions []QualitygateConditionArgs
    A list of conditions that the gate uses.
    CopyFrom string
    Name of an existing Quality Gate to copy from.
    IsDefault bool
    When set to true this Quality Gate is set as default.
    Name string
    The name of the Quality Gate to create. Maximum length 100.
    QualitygateId string
    The ID of this resource.
    conditions List<QualitygateCondition>
    A list of conditions that the gate uses.
    copyFrom String
    Name of an existing Quality Gate to copy from.
    isDefault Boolean
    When set to true this Quality Gate is set as default.
    name String
    The name of the Quality Gate to create. Maximum length 100.
    qualitygateId String
    The ID of this resource.
    conditions QualitygateCondition[]
    A list of conditions that the gate uses.
    copyFrom string
    Name of an existing Quality Gate to copy from.
    isDefault boolean
    When set to true this Quality Gate is set as default.
    name string
    The name of the Quality Gate to create. Maximum length 100.
    qualitygateId string
    The ID of this resource.
    conditions Sequence[QualitygateConditionArgs]
    A list of conditions that the gate uses.
    copy_from str
    Name of an existing Quality Gate to copy from.
    is_default bool
    When set to true this Quality Gate is set as default.
    name str
    The name of the Quality Gate to create. Maximum length 100.
    qualitygate_id str
    The ID of this resource.
    conditions List<Property Map>
    A list of conditions that the gate uses.
    copyFrom String
    Name of an existing Quality Gate to copy from.
    isDefault Boolean
    When set to true this Quality Gate is set as default.
    name String
    The name of the Quality Gate to create. Maximum length 100.
    qualitygateId String
    The ID of this resource.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Qualitygate 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 Qualitygate Resource

    Get an existing Qualitygate 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?: QualitygateState, opts?: CustomResourceOptions): Qualitygate
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            conditions: Optional[Sequence[QualitygateConditionArgs]] = None,
            copy_from: Optional[str] = None,
            is_default: Optional[bool] = None,
            name: Optional[str] = None,
            qualitygate_id: Optional[str] = None) -> Qualitygate
    func GetQualitygate(ctx *Context, name string, id IDInput, state *QualitygateState, opts ...ResourceOption) (*Qualitygate, error)
    public static Qualitygate Get(string name, Input<string> id, QualitygateState? state, CustomResourceOptions? opts = null)
    public static Qualitygate get(String name, Output<String> id, QualitygateState state, CustomResourceOptions options)
    resources:  _:    type: sonarqube:Qualitygate    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.
    The following state arguments are supported:
    Conditions List<QualitygateCondition>
    A list of conditions that the gate uses.
    CopyFrom string
    Name of an existing Quality Gate to copy from.
    IsDefault bool
    When set to true this Quality Gate is set as default.
    Name string
    The name of the Quality Gate to create. Maximum length 100.
    QualitygateId string
    The ID of this resource.
    Conditions []QualitygateConditionArgs
    A list of conditions that the gate uses.
    CopyFrom string
    Name of an existing Quality Gate to copy from.
    IsDefault bool
    When set to true this Quality Gate is set as default.
    Name string
    The name of the Quality Gate to create. Maximum length 100.
    QualitygateId string
    The ID of this resource.
    conditions List<QualitygateCondition>
    A list of conditions that the gate uses.
    copyFrom String
    Name of an existing Quality Gate to copy from.
    isDefault Boolean
    When set to true this Quality Gate is set as default.
    name String
    The name of the Quality Gate to create. Maximum length 100.
    qualitygateId String
    The ID of this resource.
    conditions QualitygateCondition[]
    A list of conditions that the gate uses.
    copyFrom string
    Name of an existing Quality Gate to copy from.
    isDefault boolean
    When set to true this Quality Gate is set as default.
    name string
    The name of the Quality Gate to create. Maximum length 100.
    qualitygateId string
    The ID of this resource.
    conditions Sequence[QualitygateConditionArgs]
    A list of conditions that the gate uses.
    copy_from str
    Name of an existing Quality Gate to copy from.
    is_default bool
    When set to true this Quality Gate is set as default.
    name str
    The name of the Quality Gate to create. Maximum length 100.
    qualitygate_id str
    The ID of this resource.
    conditions List<Property Map>
    A list of conditions that the gate uses.
    copyFrom String
    Name of an existing Quality Gate to copy from.
    isDefault Boolean
    When set to true this Quality Gate is set as default.
    name String
    The name of the Quality Gate to create. Maximum length 100.
    qualitygateId String
    The ID of this resource.

    Supporting Types

    QualitygateCondition, QualitygateConditionArgs

    Metric string
    Condition metric.
    Op string
    Condition operator. Possible values are: LT and GT
    Threshold string
    Condition error threshold (For ratings: A=1, B=2, C=3, D=4)
    Id string
    The ID of this resource.
    Metric string
    Condition metric.
    Op string
    Condition operator. Possible values are: LT and GT
    Threshold string
    Condition error threshold (For ratings: A=1, B=2, C=3, D=4)
    Id string
    The ID of this resource.
    metric String
    Condition metric.
    op String
    Condition operator. Possible values are: LT and GT
    threshold String
    Condition error threshold (For ratings: A=1, B=2, C=3, D=4)
    id String
    The ID of this resource.
    metric string
    Condition metric.
    op string
    Condition operator. Possible values are: LT and GT
    threshold string
    Condition error threshold (For ratings: A=1, B=2, C=3, D=4)
    id string
    The ID of this resource.
    metric str
    Condition metric.
    op str
    Condition operator. Possible values are: LT and GT
    threshold str
    Condition error threshold (For ratings: A=1, B=2, C=3, D=4)
    id str
    The ID of this resource.
    metric String
    Condition metric.
    op String
    Condition operator. Possible values are: LT and GT
    threshold String
    Condition error threshold (For ratings: A=1, B=2, C=3, D=4)
    id String
    The ID of this resource.

    Package Details

    Repository
    sonarqube jdamata/terraform-provider-sonarqube
    License
    Notes
    This Pulumi package is based on the sonarqube Terraform Provider.
    sonarqube logo
    sonarqube 0.16.14 published on Monday, Apr 14, 2025 by jdamata