Class Oak9Builder

    • Constructor Detail

      • Oak9Builder

        @DataBoundConstructor
        public Oak9Builder​(String orgId,
                           String projectId,
                           String projectEnvironmentId,
                           String credentialsId,
                           int maxSeverity,
                           String baseUrl,
                           int pollingTimeoutSeconds)
        Constructor is setup by Jenkins when it instantiates the plugin
        Parameters:
        orgId - the oak9-provided org ID
        projectId - the oak9-provided project ID
        projectEnvironmentId - the oak9-provided project environment ID
        credentialsId - the ID to use to fetch the oak9 API Key from Jenkins secrets
        maxSeverity - the severity at which the job will fail (at or above)
    • Method Detail

      • setOrgId

        @DataBoundSetter
        public void setOrgId​(String orgId)
        Sets the oak9 Organization ID for the runner
        Parameters:
        orgId - the oak9-provided org ID
      • setProjectId

        @DataBoundSetter
        public void setProjectId​(String projectId)
        Sets the oak9 project ID for the runner
        Parameters:
        projectId - the oak9-provided project ID
      • setProjectEnvironmentId

        @DataBoundSetter
        public void setProjectEnvironmentId​(String projectEnvironmentId)
        Sets the oak9 project environment ID for the runner
        Parameters:
        projectEnvironmentId - the oak9-provided project environment ID
      • setCredentialsId

        @DataBoundSetter
        public void setCredentialsId​(String credentialsId)
        Sets the credentials ID to be used for the runner
        Parameters:
        credentialsId - a string for the credentials ID
      • setMaxSeverity

        @DataBoundSetter
        public void setMaxSeverity​(int maxSeverity)
        Sets the severity at which the job will fail
        Parameters:
        maxSeverity - an integer representing the max severity refer to io.jenkins.plugins.oak9.utils.Severity
      • setBaseUrl

        @DataBoundSetter
        public void setBaseUrl​(String baseUrl)
        Sets the BaseURL for communication with the oak9 API
        Parameters:
        baseUrl - the base URL to use
      • setPollingTimeoutSeconds

        @DataBoundSetter
        public void setPollingTimeoutSeconds​(int pollingTimeoutSeconds)
        Sets the amount of time to wait for a validation to complete
        Parameters:
        pollingTimeoutSeconds - an integer representing the seconds to wait
      • getBaseUrl

        public String getBaseUrl()
        Returns the current base URL
        Returns:
      • getOrgId

        public String getOrgId()
        Fetches the user-specified oak9 Organization ID
        Returns:
        the org ID
      • getProjectId

        public String getProjectId()
        Fetches the Jenkins Project ID
        Returns:
        the Jenkins Project ID
      • getProjectEnvironmentId

        public String getProjectEnvironmentId()
        Fetches the Jenkins Project Environment ID
        Returns:
        the Jenkins Project Environment ID
      • getCredentialsId

        public String getCredentialsId()
        Fetches the credentials ID selected for the job
        Returns:
        The credentials ID selected for the job
      • getMaxSeverity

        public int getMaxSeverity()
        The severity at or above which the job will fail
        Returns:
        the user-provided max severity
      • getPollingTimeoutSeconds

        public int getPollingTimeoutSeconds()
        The amount of time to wait for a validation to complete
        Returns:
        the polling timeout
      • generateHttpClient

        public Oak9ApiClient generateHttpClient​(Run<?,​?> run,
                                                TaskListener taskListener)
        Generate an API client to inject
        Parameters:
        run - the Jenkins run
        taskListener - the Jenkins task listener for logging
        Returns:
        a ready-to-use http client
      • perform

        public void perform​(@NonNull
                            Run<?,​?> run,
                            @NonNull
                            FilePath workspace,
                            @NonNull
                            EnvVars env,
                            @NonNull
                            Launcher launcher,
                            @NonNull
                            TaskListener taskListener)
                     throws IOException,
                            InterruptedException
        Jenkins plugin entry point.
        Specified by:
        perform in interface SimpleBuildStep
        Parameters:
        run - the current Jenkins build
        workspace - FilePath representing the Jenkins workspace for this project
        env - Environment variables
        launcher - the Jenkins launcher
        taskListener - the Jenkins task listener, used primarily for logging and setting task status
        Throws:
        IOException - Thrown in the event of a permanent error
        InterruptedException