0

I have a Python test script in a GitHub repo that I am looking to run every few hours. Now, I know I can use Jenkins to schedule the executions and have them run locally on my machine, but my question is how do I do this without the need for my machine to be powered on? In other words, is there a way to run a script not locally and through some headless service? My company does use circleCI, is that what I would use?

cjg123
  • 473
  • 7
  • 23

1 Answers1

1

A "cron" schedule in Jenkins would let you run tests on a repeating schedule. Details from this Stack Overflow question: Configure cron job to run every 15 minutes on Jenkins

You also mentioned CircleCI, and for that you'll find some useful information about configuring the .yml file here: https://stackoverflow.com/a/22028637/7058266

Since you're using GitHub, you'll also be able to do that using GitHub Actions: How can I get Selenium tests to run in python with Github actions?

You'll need to set a cron timing in that .yml file (details in https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions):

on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  '30 5,17 * * *'

If you need more assistance, I created a video a few years ago about how to set up Jenkins for Python/pytest Selenium testing on Jenkins from Google Cloud using SeleniumBase here: https://www.youtube.com/watch?v=n-sno20R9P0

(If you're just running a Python/pytest script without Selenium, just ignore the Selenium-specific parts.)

Michael Mintz
  • 9,007
  • 6
  • 31
  • 48
  • Thanks. If I go these routes, where will the script be executed? Because I don’t want it to run locally as I don’t want to have to have my machine powered on. – cjg123 Jan 17 '22 at 00:07
  • 1
    The script would be executed from the server that hosts the CI/CD platform that you have chosen, whether that be Jenkins, CircleCI, GitHub Actions, or other. – Michael Mintz Jan 17 '22 at 00:32