3

I have some jobs that are being configured using a GitHub Organisation. This all works fine. Some of these jobs should only run on cron triggers, not on every commit to the repository.

My problem is, how can I change the triggers without actually building the job. If I modify the Jenkinsfile and push it to the repo, I can config Jenkins to either build it or not.
But if I don't want to build it on commit, I also don't seem to get any new config from my Jenkinsfile, like new cron triggers.

So how can I reconfigure cron triggers without actually running the job?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Cor Bosman
  • 336
  • 2
  • 8

2 Answers2

0

In the scripts triggered by Jenkins, you could list the files modified

git diff --name-only $GIT_PREVIOUS_COMMIT $GIT_COMMIT

If the only modified file is the Jenkisfile, you could consider not running the next step, using a condition (when)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You probably need to separate the Jenkinsfile to a separate repository than the code itself.

Another option is to have a upstream Jenkinsfile (which have only the cron trigger and activates the downstream job) and a downstream Jenkinsfile which resides in different repositories.

yorammi
  • 6,272
  • 1
  • 28
  • 34