Skip to content

Commit

Permalink
Add async option
Browse files Browse the repository at this point in the history
  • Loading branch information
ertrzyiks committed Jun 30, 2021
1 parent 8e64ccc commit 3fe0f6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ inputs:
description: 'Jenkins job timeout period. Default 30 seconds'
required: false
default: '30'
async:
description: 'Set to true if you want to just trigger the job without waiting for it to finish'
required: false
default: false
outputs:
jenkins_job_url:
description: 'URL to the job details'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
7 changes: 6 additions & 1 deletion jenkins/job_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Jenkins
class JobClient

attr_reader :jenkins_url, :jenkins_user, :jenkins_token, :job_name, :job_params, :job_timeout
attr_reader :async_mode, :jenkins_url, :jenkins_user, :jenkins_token, :job_name, :job_params, :job_timeout

DEFAULT_TIMEOUT = 30
INTERVAL_SECONDS = 10
Expand All @@ -13,6 +13,7 @@ def initialize(args)
@jenkins_user = args['INPUT_JENKINS_USER']
@jenkins_token = args['INPUT_JENKINS_TOKEN']
@job_name = args['INPUT_JOB_NAME']
@async_mode = args['INPUT_ASYNC']
@job_params = JSON.parse(args['INPUT_JOB_PARAMS'])
@job_timeout = args['INPUT_JOB_TIMEOUT'] || DEFAULT_TIMEOUT
end
Expand All @@ -21,7 +22,11 @@ def call
crumb = get_crumb
queue_item_location = queue_job(crumb, job_name, job_params)
job_run_url = get_job_run_url(queue_item_location, job_timeout)
puts "::set-output name=jenkins_job_url::#{job_run_url}"
puts "Job run URL: #{job_run_url}"

exit(0) if @async_mode

job_progress(job_run_url, job_timeout)
exit(0)
end
Expand Down

0 comments on commit 3fe0f6f

Please sign in to comment.