<commit_before>package org.jenkinsci.plugins.nouvoladivecloud;
import hudson.Launcher;
import hudson.Extension;
import hudson.util.FormValidation;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractProject;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.QueryParameter;

import javax.servlet.ServletException;

import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

/**
 * Adds the ability to run a Nouvola DiveCloud test plan as a build step.
 *
 * @author <NAME>
 */
public class NouvolaBuilder extends Builder {

    private final String planID;
    private final String apiKey;
    private final String credsPass;
    
    @DataBoundConstructor
    public NouvolaBuilder(String planID, String apiKey, String credsPass) {
        this.planID = planID;
        this.apiKey = apiKey;
        this.credsPass = credsPass;
    }

    public String getPlanID() {
        return planID;
    }

    public String getApiKey() {
        return apiKey;
    }
    
    public String getCredsPass() {
        return credsPass;
    }
    
    
    /**
     * Sends a POST request to the Nouvola DiveCloud API version 1 with the specified plan ID, API key, and encryption key (if used). 
     */
    @Override
    public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
       System.out.println("Performing...");

		String urlParameters = "creds_pass=" + credsPass;
		byte[] postData       = urlParameters.getBytes( StandardCharsets.UTF_8 );
		int    postDataLength = postData.length;
		String request        = "https://divecloud.nouvola.com/api/v1/plans/" + planID + "/run";

		try{
			URL url = new URL(request);<commit_msg>use secret for creds pass<commit_after>package org.jenkinsci.plugins.nouvoladivecloud;
import hudson.Launcher;
import hudson.Extension;
import hudson.util.FormValidation;
import hudson.util.Secret;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractProject;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.QueryParameter;

import javax.servlet.ServletException;

import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

/**
 * Adds the ability to run a Nouvola DiveCloud test plan as a build step.
 *
 * @author <NAME>
 */
public class NouvolaBuilder extends Builder {

    private final String planID;
    private final String apiKey;
    private final Secret credsPass;
    
    @DataBoundConstructor
    public NouvolaBuilder(String planID, String apiKey, String credsPass) {
        this.planID = planID;
        this.apiKey = apiKey;
        this.credsPass = Secret.fromString(credsPass);
    }

    public String getPlanID() {
        return planID;
    }

    public String getApiKey() {
        return apiKey;
    }
    
    public Secret getCredsPass() {
        return credsPass;
    }
    
    
    /**
     * Sends a POST request to the Nouvola DiveCloud API version 1 with the specified plan ID, API key, and encryption key (if used). 
     */
    @Override
    public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
       System.out.println("Performing...");

		String urlParameters = "creds_pass=" + Secret.toString(credsPass);
		byte[] postData       = urlParameters.getBytes( StandardCharsets.UTF_8 );
		int    postDataLength = postData.length;
		String request        = "https://divecloud.nouvola.com/api/v1/plans/" + planID + "/run";

		try{
			URL url = new URL(request);
{'fraction_non_alphanumeric': 0.09267296400306357, 'fraction_numerical': 0.0015317845289762573, 'mean_word_length': 3.4573378839590445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563165', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1183, 'n_words': 309}