<commit_before>require 'net/http'
require 'uri'
require 'rexml/document'
require 'json'

@new_branch = ENV['NEW_BRANCH'] || 'Release-1.0.XX'
@view_to_configure = ENV['VIEW_TO_CONFIGURE'] || 'CI-XX-Rel'

@client = JenkinsApi::Client.new(:server_url => 'http://jenkins.slidev.org', :server_port => '8080',
      :username => '', :password => '', :jenkins_path => '/jenkins', :debug => false)

def get_jobs(url)
  jobs = @client.view.list_jobs(source_view)
  
  body = JSON.parse(response.body)

  return body['jobs']
end

def fix_job(base_url)
  puts "Adjusting " + base_url + " to " + @new_branch  
  uri = URI.parse(base_url + "config.xml")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true if uri.scheme == "https"
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if uri.scheme == "https"

  req = Net::HTTP::Get.new(uri.request_uri)
  req.basic_auth 'jenkinsapi_user', 'test<PASSWORD>'

  response = http.request(req)

  body = response.body<commit_msg>require 'jenkins_api_client' added<commit_after>require 'net/http'
require 'uri'
require 'rexml/document'
require 'json'
require 'jenkins_api_client'

@new_branch = ENV['NEW_BRANCH'] || 'Release-1.0.XX'
@view_to_configure = ENV['VIEW_TO_CONFIGURE'] || 'CI-XX-Rel'

@client = JenkinsApi::Client.new(:server_url => 'http://jenkins.slidev.org', :server_port => '8080',
      :username => '', :password => '', :jenkins_path => '/jenkins', :debug => false)

def get_jobs(url)
  jobs = @client.view.list_jobs(source_view)
  
  body = JSON.parse(response.body)

  return body['jobs']
end

def fix_job(base_url)
  puts "Adjusting " + base_url + " to " + @new_branch  
  uri = URI.parse(base_url + "config.xml")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true if uri.scheme == "https"
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if uri.scheme == "https"

  req = Net::HTTP::Get.new(uri.request_uri)
  req.basic_auth 'jenkinsapi_user', '<PASSWORD>1234'

  response = http.request(req)

  body = response.body
{'fraction_non_alphanumeric': 0.17220543806646527, 'fraction_numerical': 0.008056394763343404, 'mean_word_length': 4.759420289855073, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1861821', 'n_tokens_mistral': 759, 'n_tokens_neox': 735, 'n_words': 135}