-
Notifications
You must be signed in to change notification settings - Fork 10
DevOps: Run rails tasks from a VAEC Jenkins Instance
Emmanuel Nwakire edited this page Jul 12, 2024
·
4 revisions
- Have an account
- Browse to http://internal-jenkinsdevops-837096002.us-gov-west-1.elb.amazonaws.com/
- Log in
- Click on "Task"
- Click on "Configure" from the side navigation
- Scroll down to "Build"
- In the "Execute shell" section and "Command" textarea, type the following command
ssh ec2-user@[SERVER VARIABLE] "sudo docker exec [CONTAINER NAME] rails [RAKE TASK COMMAND];"
Replace [SERVER VARIABLE]
with the variable of the server you want to run this task on:
- production:
$PROD_SERVER
- staging:
$STG_SERVER
- development:
$DEV_SERVER
Replace [CONTAINER NAME]
with the name of the docker container
for the application: diffusion-marketplace_app_1
Replace [RAKE TASK COMMAND]
with the name of the task you want to run.
For a full list of available tasks, you can run rake --tasks
in your local project folder.
- ex:
milestones:port_milestones_to_timelines
So an example command would look like this:
ssh ec2-user@$DEV_SERVER "sudo docker exec diffusion-marketplace_app_1 rails milestones:port_milestones_to_timelines;"
- Click "Save"
- Click "Build Now"
- Click the task number in the "Build History"
- Click "Console Output"
- Ensure you see "SUCCESS" in the logs
An example of a more advanced command may look like this:
ssh ec2-user@$PROD_SERVER "sudo docker exec diffusion-marketplace_app_1 rails runner \"ActiveRecord::Base.logger = nil; counter = 0; Practice.where(published: true).order(name: :asc).each { |p| if p.diffusion_histories.empty? then counter += 1; puts %Q(ID: #{p.id}, Name: #{p.name}, #{p.user&.email.present? ? %Q(Owner email: #{p.user&.email}, ) : ''}Support email: #{p.support_network_email}, URL: https://marketplace.va.gov/practices/#{p.slug}) end }; puts %Q(Total: #{counter}); nil; STDOUT.flush\";"