<commit_before>package org.jenkinsci.plugins.TFSTrigger;

import antlr.ANTLRException;
import com.microsoft.tfs.core.TFSTeamProjectCollection;
import com.microsoft.tfs.core.clients.framework.location.ConnectOptions;
import com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient;
import com.microsoft.tfs.core.clients.versioncontrol.exceptions.ServerPathFormatException;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.*;
import com.microsoft.tfs.core.clients.versioncontrol.specs.version.DateVersionSpec;
import com.microsoft.tfs.core.clients.versioncontrol.specs.version.VersionSpec;
import com.microsoft.tfs.core.httpclient.Credentials;
import com.microsoft.tfs.core.httpclient.UsernamePasswordCredentials;
import hudson.Extension;
import hudson.model.*;
import hudson.model.Item;
import hudson.triggers.Trigger;
import hudson.util.SequentialExecutionQueue;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.jenkinsci.lib.xtrigger.XTriggerDescriptor;
import org.jenkinsci.lib.xtrigger.XTriggerException;
import org.jenkinsci.lib.xtrigger.XTriggerLog;
import org.kohsuke.stapler.DataBoundConstructor;
import org.jenkinsci.lib.xtrigger.AbstractTrigger;
import org.kohsuke.stapler.StaplerRequest;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Executors;

public class TFSTrigger extends AbstractTrigger {

    private String tfsServerUrl = null;
    private String tfsServerUsername = null;
    private String tfsServerPassword = null;

    private List<TFSProjectPath> tfsProjectPaths = new ArrayList<TFSProjectPath>();

    @DataBoundConstructor
    public TFSTrigger(String cronTabSpec, String tfsServerUrl, String tfsServerUsername, String tfsServerPassword,
                      List<TFSProjectPath> tfsProjectPaths) throws ANTLRException {
        super(cronTabSpec);

        this.tfsServerUrl = tfsServerUrl;
        this.tfsServerUsername = tfsServerUsername;
        this.tfsServerPassword = <PASSWORD>ServerPassword;
        this.tfsProjectPaths = tfsProjectPaths;

    }

    public List<TFSProjectPath> getTfsProjectPaths() {
        return tfsProjectPaths;
    }

    public String getTfsServerUrl() {
        return tfsServerUrl;
    }

    public String getTfsServerUsername() {
        return tfsServerUsername;
    }

    public String getTfsServerPassword() {
        return <PASSWORD>ServerPassword;
    }

    @Override
    protected File getLogFile() {
        return new File(job.getRootDir(), "tfsbuildtrigger-polling.log");
    }

    @Override
    protected boolean requiresWorkspaceForPolling() {
        return false;
    }

    @Override
    protected boolean checkIfModified(Node pollingNode, XTriggerLog log) throws XTriggerException {

        Boolean changesFound = false;

        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");

        log.info("Ensuring native libraries are configured...");
        ensureNativeLibrariesConfigured(log);
        log.info("Done.");

        try {
            log.info("Beginning check for modifications.");

            if (tfsProjectPaths != null && !tfsProjectPaths.isEmpty()) {

                log.info("Establishing connection to TFS...");
                TFSTeamProjectCollection projectCollection = getTeamProjectCollection();
                VersionControlClient versionControlClient = projectCollection.getVersionControlClient();
                log.info("Done.");

                Calendar lastBuildDate = getDateAndTimeOfLastBuild(log);
                Calendar currentTime = Calendar.getInstance();

                if (lastBuildDate == null) {
                    log.info("No builds have been performed, assuming a build needs to happen.");
                    return true;<commit_msg>Add additional logging when an exception is throwing while connecting to TFS<commit_after>package org.jenkinsci.plugins.TFSTrigger;

import antlr.ANTLRException;
import com.microsoft.tfs.core.TFSTeamProjectCollection;
import com.microsoft.tfs.core.clients.framework.location.ConnectOptions;
import com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient;
import com.microsoft.tfs.core.clients.versioncontrol.exceptions.ServerPathFormatException;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.*;
import com.microsoft.tfs.core.clients.versioncontrol.specs.version.DateVersionSpec;
import com.microsoft.tfs.core.clients.versioncontrol.specs.version.VersionSpec;
import com.microsoft.tfs.core.httpclient.Credentials;
import com.microsoft.tfs.core.httpclient.UsernamePasswordCredentials;
import hudson.Extension;
import hudson.model.*;
import hudson.model.Item;
import hudson.triggers.Trigger;
import hudson.util.SequentialExecutionQueue;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.jenkinsci.lib.xtrigger.XTriggerDescriptor;
import org.jenkinsci.lib.xtrigger.XTriggerException;
import org.jenkinsci.lib.xtrigger.XTriggerLog;
import org.kohsuke.stapler.DataBoundConstructor;
import org.jenkinsci.lib.xtrigger.AbstractTrigger;
import org.kohsuke.stapler.StaplerRequest;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Executors;

public class TFSTrigger extends AbstractTrigger {

    private String tfsServerUrl = null;
    private String tfsServerUsername = null;
    private String tfsServerPassword = null;

    private List<TFSProjectPath> tfsProjectPaths = new ArrayList<TFSProjectPath>();

    @DataBoundConstructor
    public TFSTrigger(String cronTabSpec, String tfsServerUrl, String tfsServerUsername, String tfsServerPassword,
                      List<TFSProjectPath> tfsProjectPaths) throws ANTLRException {
        super(cronTabSpec);

        this.tfsServerUrl = tfsServerUrl;
        this.tfsServerUsername = tfsServerUsername;
        this.tfsServerPassword = <PASSWORD>;
        this.tfsProjectPaths = tfsProjectPaths;

    }

    public List<TFSProjectPath> getTfsProjectPaths() {
        return tfsProjectPaths;
    }

    public String getTfsServerUrl() {
        return tfsServerUrl;
    }

    public String getTfsServerUsername() {
        return tfsServerUsername;
    }

    public String getTfsServerPassword() {
        return tfsServerPassword;
    }

    @Override
    protected File getLogFile() {
        return new File(job.getRootDir(), "tfsbuildtrigger-polling.log");
    }

    @Override
    protected boolean requiresWorkspaceForPolling() {
        return false;
    }

    @Override
    protected boolean checkIfModified(Node pollingNode, XTriggerLog log) throws XTriggerException {

        Boolean changesFound = false;

        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");

        log.info("Ensuring native libraries are configured...");
        ensureNativeLibrariesConfigured(log);
        log.info("Done.");

        try {
            log.info("Beginning check for modifications.");

            if (tfsProjectPaths != null && !tfsProjectPaths.isEmpty()) {

                TFSTeamProjectCollection projectCollection = null;
                VersionControlClient versionControlClient = null;

                log.info("Establishing connection to TFS...");
                try {
                    projectCollection = getTeamProjectCollection();
                    versionControlClient = projectCollection.getVersionControlClient();
                } catch (com.microsoft.tfs.core.exceptions.TECoreException ex) {
                    log.info("TFS Exception caught: " + ex.getMessage());
                    throw ex;
                }
                log.info("Done.");

                Calendar lastBuildDate = getDateAndTimeOfLastBuild(log);
                Calendar currentTime = Calendar.getInstance();

                if (lastBuildDate == null) {
                    log.info("No builds have been performed, assuming a build needs to happen.");
                    return true;
{'fraction_non_alphanumeric': 0.08696176577011216, 'fraction_numerical': 0.0, 'mean_word_length': 3.4773218142548594, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, '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': '6438946', 'n_tokens_mistral': 2352, 'n_tokens_neox': 2235, 'n_words': 448}