Skip to content

Commit

Permalink
Merge pull request #1 from toptal/fix-INPUT_JENKINS_URL-when-trailing…
Browse files Browse the repository at this point in the history
…-slash-is-missing

Make jenkins URL param work with and without trailing slash
  • Loading branch information
romanrod authored Aug 26, 2021
2 parents 182bc5d + fb0f72b commit 23c12d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jenkins/job_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JobClient
INTERVAL_SECONDS = 10

def initialize(args)
@jenkins_url = args['INPUT_JENKINS_URL']
@jenkins_url = args['INPUT_JENKINS_URL'].chomp('/')
@jenkins_user = args['INPUT_JENKINS_USER']
@jenkins_token = args['INPUT_JENKINS_TOKEN']
@job_name = args['INPUT_JOB_NAME']
Expand Down Expand Up @@ -52,7 +52,7 @@ def get_crumb
def queue_job(crumb, job_name, job_params)
query_string = ''
job_params&.each_pair { |k, v| query_string +="#{k}=#{v}&" }
job_queue_url = "#{jenkins_url}job/#{job_name}/buildWithParameters?#{query_string}".chop
job_queue_url = "#{jenkins_url}/job/#{job_name}/buildWithParameters?#{query_string}".chop
queue_response = perform_request(job_queue_url, :post, params: { 'token': jenkins_token }, headers: {'Jenkins-Crumb': crumb})
queue_item_location = queue_response.headers[:location]
queue_item_location
Expand Down

0 comments on commit 23c12d5

Please sign in to comment.