I am able to trigger a new Jenkins build every time code is committed into GitHub.
Example of a Jenkinsfile in GitHub:
node ('aws-slaves') {
stage ('Gate 1: Checkout Code') {
wrap([$class: 'TimestamperBuildWrapper']) {
echo "Deleting dir"
deleteDir()
}
}
}
How do I pass parameter from another GitHub file (that is in the same repo) and print parameter value?
I was exploring different ways to do it and here is one way:
Inside a Jenkins file - you can set to execute a 'shell' script. One of the commands from a shell script can be 'curl'. With a curl command - value from a GitHub repository (from a specific file in it) can be printed to a screen, it can be saved into a file or stored in temporary variable. In that way - build can be parametrized via github by storing specific values in separate files (in github repository) and content of a file can be read during a build.
Another way is to use a jenkins hook inside github which will trigger a build every time code is committed. During that build - whole github repository (where code is committed) will be fetched and stored inside temporary directory on a server where Jenkins is running. From that (local) folder - any file from a (cloned) repository can be read into a variable and in that way parameterization can be achieved as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.