Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins scheduled build Triggers with environment variable?

I want to build periodically with environment variable in jenkins:

#pseudo setting
H 17 * * * BUILD_FOR=gist-mail TOKEN_GIST_MAIL=some_token
H 17 * * * BUILD_FOR=pollyanna TOKEN_POLLYANNA=anothor_token
H 17 * * * BUILD_FOR=fenix-knight TOKEN_FENIX_KNIGHT=alternative_token

These variables do not change dynamically, given in advance.

I got a error below:

Invalid input: "10 17 * * * BUILD_FOR=fenix-knight": line 1:12: expecting EOF, found ' '

How do I pass different environment variable to each build trigger? My work around is create each jobs.

My executing shell below:

gem install bundler
ruby -i -pe '$_.gsub! /^ruby/, "#ruby"' Gemfile
bundle
BUILD_FOR=fenix-knight bundle exec rake tachikoma:load tachikoma:fetch tachikoma:bundle tachikoma:pull_request
like image 919
Matt - sanemat Avatar asked Oct 18 '25 04:10

Matt - sanemat


1 Answers

There is a parameterized build plugin for your situation Jenkins - triggering a parameterized build has a good demonstration of how to use it and also another plugin to show the parameters which went into it.

You could also look at the multijob plugin https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin to run one underlying job with separate parameters

like image 174
KeepCalmAndCarryOn Avatar answered Oct 20 '25 08:10

KeepCalmAndCarryOn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!