Class DatadogGlobalConfiguration

    • Constructor Detail

      • DatadogGlobalConfiguration

        @DataBoundConstructor
        public DatadogGlobalConfiguration()
    • Method Detail

      • loadEnvVariables

        public void loadEnvVariables()
      • doCheckAgentConnectivityLogs

        public FormValidation doCheckAgentConnectivityLogs​(@QueryParameter("targetHost")
                                                           String targetHost,
                                                           @QueryParameter("targetLogCollectionPort")
                                                           String targetLogCollectionPort)
        Test the connection to the Logs Collection port in the Datadog Agent.
        Parameters:
        targetHost - - The Datadog Agent host
        targetLogCollectionPort - - The Logs Collection port used to report logs in the Datadog Agent
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckAgentConnectivityTraces

        public FormValidation doCheckAgentConnectivityTraces​(@QueryParameter("targetHost")
                                                             String targetHost,
                                                             @QueryParameter("targetTraceCollectionPort")
                                                             String targetTraceCollectionPort)
        Test the connection to the Traces Collection port in the Datadog Agent.
        Parameters:
        targetHost - - The Datadog Agent host
        targetTraceCollectionPort - - The Traces Collection port used to report logs in the Datadog Agent
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • getCredentialFromId

        public org.jenkinsci.plugins.plaincredentials.StringCredentials getCredentialFromId​(String credentialId)
        Gets the StringCredentials object for the given credential ID
        Parameters:
        credentialId - - The Id of the credential to get
        Returns:
        a StringCredentials object
      • findSecret

        public Secret findSecret​(String apiKey,
                                 String credentialsApiKey)
        Gets the correct Secret object representing the API key used for authentication to Datadog If a Credential is provided, then use the credential, if not, default to the text submission
        Parameters:
        apiKey - - The text API key the user submitted
        credentialsApiKey - - The Id of the credential the user submitted
        Returns:
        a Secret object representing the API key used for authentication to Datadog
      • doTestConnection

        public FormValidation doTestConnection​(@QueryParameter("targetApiKey")
                                               String targetApiKey,
                                               @QueryParameter("targetCredentialsApiKey")
                                               String targetCredentialsApiKey,
                                               @QueryParameter("targetApiURL")
                                               String targetApiURL)
                                        throws IOException,
                                               javax.servlet.ServletException
        Tests the apiKey field from the configuration screen, to check its' validity. It is used in the config.jelly resource file. See method="testConnection"
        Parameters:
        targetApiURL - - The API Url to validate the apikey.
        targetApiKey - - A String containing the apiKey submitted from the form on the configuration screen, which will be used to authenticate a request to the Datadog API.
        targetCredentialsApiKey - - A String containing the API key as a credential, if it is not specified, try the connection with the targetApiKey
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
        Throws:
        IOException - if there is an input/output exception.
        javax.servlet.ServletException - if there is a servlet exception.
      • doFillTargetCredentialsApiKeyItems

        public ListBoxModel doFillTargetCredentialsApiKeyItems​(@AncestorInPath
                                                               Item item,
                                                               @QueryParameter("targetCredentialsApiKey")
                                                               String targetCredentialsApiKey)
        Populates the targetCredentialsApiKey field from the configuration screen with all of the valid credentials
        Parameters:
        item - - The context within which to list available credentials
        targetCredentialsApiKey - - A String containing the API key as a credential
        Returns:
        a ListBoxModel object used to display all of the available credentials.
      • doTestFilteringConfig

        public FormValidation doTestFilteringConfig​(@QueryParameter("emitSecurityEvents")
                                                    boolean emitSecurityEvents,
                                                    @QueryParameter("emitSystemEvents")
                                                    boolean emitSystemEvents,
                                                    @QueryParameter("includeEvents")
                                                    String includeEvents,
                                                    @QueryParameter("excludeEvents")
                                                    String excludeEvents)
        Checks filtering config for comma-separated list, overlapping include/exclude lists, unrecognizable event names, and redundant inclusion/exclusion.
        Parameters:
        emitSecurityEvents - toggle to send security events
        emitSystemEvents - toggle to send system events
        includeEvents - string of included events list (comma-separated)
        excludeEvents - string of excluded events list (comma-separated)
        Returns:
        FormValidation.error() if not formatted correctly or overlapping lists, FormValidation.warning() for redundant config, and FormValidation.ok() for all else
      • doCheckTargetCredentialsApiKey

        public FormValidation doCheckTargetCredentialsApiKey​(@AncestorInPath
                                                             Item item,
                                                             @QueryParameter("targetCredentialsApiKey")
                                                             String targetCredentialsApiKey)
        Tests the targetCredentialsApiKey field from the configuration screen, to check its' validity.
        Parameters:
        item - - The context within which to list available credentials.
        targetCredentialsApiKey - - A String containing the API key as a credential
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doTestHostname

        public FormValidation doTestHostname​(@QueryParameter("hostname")
                                             String hostname)
        Tests the hostname field from the configuration screen, to determine if the hostname is of a valid format, according to the RFC 1123. It is used in the config.jelly resource file. See method="testHostname"
        Parameters:
        hostname - - A String containing the hostname submitted from the form on the configuration screen, which will be used to authenticate a request to the Datadog API.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckTargetApiURL

        public FormValidation doCheckTargetApiURL​(@QueryParameter("targetApiURL")
                                                  String targetApiURL)
        Parameters:
        targetApiURL - - The API URL which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckTargetLogIntakeURL

        public FormValidation doCheckTargetLogIntakeURL​(@QueryParameter("targetLogIntakeURL")
                                                        String targetLogIntakeURL)
        Parameters:
        targetLogIntakeURL - - The Log Intake URL which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckTargetWebhookIntakeURL

        public FormValidation doCheckTargetWebhookIntakeURL​(@QueryParameter("targetWebhookIntakeURL")
                                                            String targetWebhookIntakeURL)
        Parameters:
        targetWebhookIntakeURL - - The Webhook Intake URL which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • validateURL

        public static boolean validateURL​(String targetURL)
      • doCheckTargetHost

        public FormValidation doCheckTargetHost​(@QueryParameter("targetHost")
                                                String targetHost)
        Parameters:
        targetHost - - The dogStatsD Host which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • validatePort

        public static boolean validatePort​(String targetPort)
      • doCheckTargetPort

        public FormValidation doCheckTargetPort​(@QueryParameter("targetPort")
                                                String targetPort)
        Parameters:
        targetPort - - The dogStatsD Port which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckTargetLogCollectionPort

        public FormValidation doCheckTargetLogCollectionPort​(@QueryParameter("targetLogCollectionPort")
                                                             String targetLogCollectionPort)
        Parameters:
        targetLogCollectionPort - - The Log Collection Port which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckTargetTraceCollectionPort

        public FormValidation doCheckTargetTraceCollectionPort​(@QueryParameter("targetTraceCollectionPort")
                                                               String targetTraceCollectionPort)
        Parameters:
        targetTraceCollectionPort - - The Trace Collection Port which the plugin will report to.
        Returns:
        a FormValidation object used to display a message to the user on the configuration screen.
      • doCheckTraceServiceName

        public FormValidation doCheckTraceServiceName​(@QueryParameter("traceServiceName")
                                                      String traceServiceName)
      • isApplicable

        public boolean isApplicable​(Class<? extends AbstractProject> aClass)
        Indicates if this builder can be used with all kinds of project types.
        Parameters:
        aClass - - An extension of the AbstractProject class representing a specific type of project.
        Returns:
        a boolean signifying whether or not a builder can be used with a specific type of project.
      • getDisplayName

        public String getDisplayName()
        Getter function for a human readable plugin name, used in the configuration screen.
        Overrides:
        getDisplayName in class Descriptor<GlobalConfiguration>
        Returns:
        a String containing the human readable display name for this plugin.
      • configure

        public boolean configure​(org.kohsuke.stapler.StaplerRequest req,
                                 net.sf.json.JSONObject formData)
                          throws Descriptor.FormException
        Indicates if this builder can be used with all kinds of project types.
        Overrides:
        configure in class GlobalConfiguration
        Parameters:
        req - - A StaplerRequest object
        formData - - A JSONObject containing the submitted form data from the configuration screen.
        Returns:
        a boolean signifying the success or failure of configuration.
        Throws:
        Descriptor.FormException - if the formData is invalid.
      • reportWithEquals

        public boolean reportWithEquals​(String value)
      • getReportWith

        public String getReportWith()
        Getter function for the reportWith global configuration.
        Returns:
        a String containing the reportWith global configuration.
      • setReportWith

        @DataBoundSetter
        public void setReportWith​(String reportWith)
        Setter function for the reportWith global configuration.
        Parameters:
        reportWith - = A string containing the reportWith global configuration.
      • getTargetApiURL

        public String getTargetApiURL()
        Getter function for the targetApiURL global configuration.
        Returns:
        a String containing the targetApiURL global configuration.
      • setTargetApiURL

        @DataBoundSetter
        public void setTargetApiURL​(String targetApiURL)
        Setter function for the targetApiURL global configuration.
        Parameters:
        targetApiURL - = A string containing the DataDog API URL
      • setTargetLogIntakeURL

        @DataBoundSetter
        public void setTargetLogIntakeURL​(String targetLogIntakeURL)
        Setter function for the targetLogIntakeURL global configuration.
        Parameters:
        targetLogIntakeURL - = A string containing the DataDog Log Intake URL
      • getTargetLogIntakeURL

        public String getTargetLogIntakeURL()
        Getter function for the targetLogIntakeURL global configuration.
        Returns:
        a String containing the targetLogIntakeURL global configuration.
      • setTargetWebhookIntakeURL

        @DataBoundSetter
        public void setTargetWebhookIntakeURL​(String targetWebhookIntakeURL)
        Setter function for the targetWebhookIntakeURL global configuration.
        Parameters:
        targetWebhookIntakeURL - = A string containing the DataDog Webhook Intake URL
      • getTargetWebhookIntakeURL

        public String getTargetWebhookIntakeURL()
        Getter function for the targetWebhookIntakeURL global configuration.
        Returns:
        a String containing the targetWebhookIntakeURL global configuration.
      • getTargetApiKey

        public Secret getTargetApiKey()
        Getter function for the targetApiKey global configuration.
        Returns:
        a Secret containing the targetApiKey global configuration.
      • setTargetApiKey

        @DataBoundSetter
        public void setTargetApiKey​(String targetApiKey)
        Setter function for the apiKey global configuration.
        Parameters:
        targetApiKey - = A string containing the plaintext representation of a DataDog API Key
      • getUsedApiKey

        public Secret getUsedApiKey()
        Getter function for the API key global configuration.
        Returns:
        a Secret containing the usedApiKey global configuration.
      • setUsedApiKey

        @DataBoundSetter
        public void setUsedApiKey​(Secret usedApiKey)
        Setter function for the API key global configuration..
        Parameters:
        usedApiKey - = A Secret containing the DataDog API Key
      • getTargetCredentialsApiKey

        public String getTargetCredentialsApiKey()
        Getter function for the targetCredentialsApiKey global configuration.
        Returns:
        a String containing the ID of the targetCredentialsApiKey global configuration.
      • setTargetCredentialsApiKey

        @DataBoundSetter
        public void setTargetCredentialsApiKey​(String targetCredentialsApiKey)
        Setter function for the credentials apiKey global configuration.
        Parameters:
        targetCredentialsApiKey - = A string containing the plaintext representation of a DataDog API Key
      • getTargetHost

        public String getTargetHost()
        Getter function for the targetHost global configuration.
        Returns:
        a String containing the targetHost global configuration.
      • setTargetHost

        @DataBoundSetter
        public void setTargetHost​(String targetHost)
        Setter function for the targetHost global configuration.
        Parameters:
        targetHost - = A string containing the DogStatsD Host
      • getTargetPort

        public Integer getTargetPort()
        Getter function for the targetPort global configuration.
        Returns:
        a Integer containing the targetPort global configuration.
      • setTargetPort

        @DataBoundSetter
        public void setTargetPort​(Integer targetPort)
        Setter function for the targetPort global configuration.
        Parameters:
        targetPort - = A string containing the DogStatsD Port
      • getTargetLogCollectionPort

        public Integer getTargetLogCollectionPort()
        Getter function for the targetLogCollectionPort global configuration.
        Returns:
        a Integer containing the targetLogCollectionPort global configuration.
      • setTargetLogCollectionPort

        @DataBoundSetter
        public void setTargetLogCollectionPort​(Integer targetLogCollectionPort)
        Setter function for the targetLogCollectionPort global configuration.
        Parameters:
        targetLogCollectionPort - = A string containing the Log Collection Port
      • getTargetTraceCollectionPort

        public Integer getTargetTraceCollectionPort()
        Getter function for the targetTraceCollectionPort global configuration.
        Returns:
        a Integer containing the targetTraceCollectionPort global configuration.
      • setTargetTraceCollectionPort

        @DataBoundSetter
        public void setTargetTraceCollectionPort​(Integer targetTraceCollectionPort)
        Setter function for the targetLogCollectionPort global configuration.
        Parameters:
        targetTraceCollectionPort - = A string containing the Trace Collection Port
      • getTraceServiceName

        @Deprecated
        public String getTraceServiceName()
        Deprecated.
        use getCiInstanceName.
        Getter function for the traceServiceName global configuration.
        Returns:
        a String containing the traceServiceName global configuration.
      • setTraceServiceName

        @Deprecated
        @DataBoundSetter
        public void setTraceServiceName​(String traceServiceName)
        Deprecated.
        Use setCiInstanceName.
        Setter function for the traceServiceName global configuration.
        Parameters:
        traceServiceName - = A string containing the Trace Service Name
      • getCiInstanceName

        public String getCiInstanceName()
        Getter function for the traceServiceName global configuration.
        Returns:
        a String containing the traceServiceName global configuration.
      • setCiInstanceName

        public void setCiInstanceName​(String ciInstanceName)
        Setter function for the traceServiceName global configuration.
        Parameters:
        ciInstanceName - = A string containing the CI Instance Name
      • getHostname

        public String getHostname()
        Getter function for the hostname global configuration.
        Returns:
        a String containing the hostname global configuration.
      • setHostname

        @DataBoundSetter
        public void setHostname​(String hostname)
        Setter function for the hostname global configuration.
        Parameters:
        hostname - - A String containing the hostname of the Jenkins host.
      • getBlacklist

        @Deprecated
        public String getBlacklist()
        Deprecated.
        replaced by getExcluded()
        Returns:
        a String array containing the excluded global configuration.
      • getExcluded

        public String getExcluded()
        Getter function for the excluded global configuration, containing a comma-separated list of jobs to exclude from monitoring.
        Returns:
        a String array containing the excluded global configuration.
      • setBlacklist

        @Deprecated
        @DataBoundSetter
        public void setBlacklist​(String jobs)
        Deprecated.
        Parameters:
        jobs - - a comma-separated list of jobs to exclude from monitoring.
      • setExcluded

        @DataBoundSetter
        public void setExcluded​(String jobs)
        Setter function for the excluded jobs global configuration, accepting a comma-separated string of jobs.
        Parameters:
        jobs - - a comma-separated list of jobs to exclude from monitoring.
      • getWhitelist

        @Deprecated
        public String getWhitelist()
        Deprecated.
        replaced by getIncluded()
        Returns:
        a String array containing the included global configuration.
      • getIncluded

        public String getIncluded()
        Getter function for the included global configuration, containing a comma-separated list of jobs to include for monitoring.
        Returns:
        a String array containing the included global configuration.
      • setWhitelist

        @Deprecated
        @DataBoundSetter
        public void setWhitelist​(String jobs)
        Deprecated.
        Parameters:
        jobs - - a comma-separated list of jobs to include for monitoring.
      • setIncluded

        @DataBoundSetter
        public void setIncluded​(String jobs)
        Setter function for the includedd global configuration, accepting a comma-separated string of jobs.
        Parameters:
        jobs - - a comma-separated list of jobs to include for monitoring.
      • isEmitConfigChangeEvents

        public boolean isEmitConfigChangeEvents()
        Returns:
        - A Boolean indicating if the user has configured Datadog to emit Config Change events.
      • setEmitConfigChangeEvents

        @DataBoundSetter
        public void setEmitConfigChangeEvents​(boolean emitConfigChangeEvents)
        Used for CasC accepting a comma-separated string of events.
        Parameters:
        emitConfigChangeEvents - - The checkbox status (checked/unchecked)
      • getGlobalTagFile

        public String getGlobalTagFile()
        Gets the globalTagFile set in the job configuration.
        Returns:
        a String representing the relative path to a globalTagFile
      • setGlobalTagFile

        @DataBoundSetter
        public void setGlobalTagFile​(String globalTagFile)
        Setter function for the globalFile global configuration, accepting a comma-separated string of tags.
        Parameters:
        globalTagFile - - a comma-separated list of tags.
      • getGlobalTags

        public String getGlobalTags()
        Getter function for the globalTags global configuration, containing a comma-separated list of tags that should be applied everywhere.
        Returns:
        a String array containing the globalTags global configuration
      • setGlobalTags

        @DataBoundSetter
        public void setGlobalTags​(String globalTags)
        Setter function for the globalTags global configuration, accepting a comma-separated string of tags.
        Parameters:
        globalTags - - a comma-separated list of tags.
      • getGlobalJobTags

        public String getGlobalJobTags()
        Getter function for the globalJobTags global configuration, containing a comma-separated list of jobs and tags that should be applied to them
        Returns:
        a String array containing the globalJobTags global configuration.
      • setGlobalJobTags

        @DataBoundSetter
        public void setGlobalJobTags​(String globalJobTags)
        Setter function for the globalJobTags global configuration, accepting a comma-separated string of jobs and tags.
        Parameters:
        globalJobTags - - a comma-separated list of jobs to include from monitoring.
      • isRetryLogs

        public boolean isRetryLogs()
        Returns:
        - A Boolean indicating if the user has configured Datadog to retry sending logs.
      • setRetryLogs

        @DataBoundSetter
        public void setRetryLogs​(boolean retryLogs)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        retryLogs - - The checkbox status (checked/unchecked)
      • isRefreshDogstatsdClient

        public boolean isRefreshDogstatsdClient()
        Returns:
        - A Boolean indicating if the user has configured Datadog to refresh the dogstatsd client
      • setRefreshDogstatsdClient

        @DataBoundSetter
        public void setRefreshDogstatsdClient​(boolean refreshDogstatsdClient)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        refreshDogstatsdClient - - The checkbox status (checked/unchecked)
      • isCacheBuildRuns

        public boolean isCacheBuildRuns()
        Returns:
        - A Boolean indicating if the user has configured Datadog to cache build runs
      • setCacheBuildRuns

        @DataBoundSetter
        public void setCacheBuildRuns​(boolean cacheBuildRuns)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        cacheBuildRuns - - The checkbox status (checked/unchecked)
      • isUseAwsInstanceHostname

        public boolean isUseAwsInstanceHostname()
        Returns:
        - A Boolean indicating if the user has configured Datadog to use AWS instance as hostname
      • setUseAwsInstanceHostname

        @DataBoundSetter
        public void setUseAwsInstanceHostname​(boolean useAwsInstanceHostname)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        useAwsInstanceHostname - - The checkbox status (checked/unchecked)
      • isEmitSecurityEvents

        public boolean isEmitSecurityEvents()
        Returns:
        - A Boolean indicating if the user has configured Datadog to emit Security related events.
      • setEmitSecurityEvents

        @DataBoundSetter
        public void setEmitSecurityEvents​(boolean emitSecurityEvents)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        emitSecurityEvents - - The checkbox status (checked/unchecked)
      • isEmitSystemEvents

        public boolean isEmitSystemEvents()
        Returns:
        - A Boolean indicating if the user has configured Datadog to emit System related events.
      • setEmitSystemEvents

        @DataBoundSetter
        public void setEmitSystemEvents​(boolean emitSystemEvents)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        emitSystemEvents - - The checkbox status (checked/unchecked)
      • setIncludeEvents

        @DataBoundSetter
        public void setIncludeEvents​(String events)
                              throws InvalidAttributeValueException
        Setter function for the included global configuration, accepting a comma-separated string of events.
        Parameters:
        events - - a comma-separated list of events to include for sending to agent.
        Throws:
        InvalidAttributeValueException
      • getIncludeEvents

        public String getIncludeEvents()
        Getter function for the included global configuration, containing a comma-separated list of events to send to agent.
        Returns:
        a String array containing the events included global configuration.
      • setExcludeEvents

        @DataBoundSetter
        public void setExcludeEvents​(String events)
                              throws InvalidAttributeValueException
        Setter function for the included global configuration, accepting a comma-separated string of events.
        Parameters:
        events - - a comma-separated list of events to exclude for sending to agent.
        Throws:
        InvalidAttributeValueException
      • getExcludeEvents

        public String getExcludeEvents()
        Getter function for the included global configuration, containing a comma-separated list of events not to send.
        Returns:
        a String array containing the events included global configuration.
      • isCollectBuildLogs

        public boolean isCollectBuildLogs()
        Returns:
        - A Boolean indicating if the user has configured Datadog to collect logs.
      • setCollectBuildLogs

        @DataBoundSetter
        public void setCollectBuildLogs​(boolean collectBuildLogs)
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        collectBuildLogs - - The checkbox status (checked/unchecked)
      • isCollectBuildTraces

        @Deprecated
        public boolean isCollectBuildTraces()
        Deprecated.
        Use isEnabledCiVisibility
        Returns:
        - A Boolean indicating if the user has configured Datadog to collect traces.
      • setCollectBuildTraces

        @DataBoundSetter
        @Deprecated
        public void setCollectBuildTraces​(boolean collectBuildTraces)
        Deprecated.
        Use setEnableCiVisibility
        Set the checkbox in the UI, used for Jenkins data binding
        Parameters:
        collectBuildTraces - - The checkbox status (checked/unchecked)
      • getEnableCiVisibility

        public boolean getEnableCiVisibility()
        Returns:
        - A Boolean indicating if the user has configured Datadog to enable CI Visibility.
      • setEnableCiVisibility

        @DataBoundSetter
        public void setEnableCiVisibility​(boolean enableCiVisibility)
        Set the checkbox in the UI, used for Jenkins data binding to enable CI Visibility
        Parameters:
        enableCiVisibility - - The checkbox status (checked/unchecked)