The sh invocation, is wrapped in the sshagent, to make it reuse the appropriateĬredentials from the Jenkins credential store. Then invoke a shell command to select the tag, based on the version pattern, we have obtained above, and checkout it (5.3.* style wildcards should also work). Next we fetch/clone the "Component B", with the changelog: false, poll: false flags, to prevent it from being registered for the SCM poll, into the "module/b" folder of the current workspace. There are also readYaml, readJSON commands available. Here we use the "readProperties" command, which is part of the Pipeline Utility Steps Plugin to extract the "Component B" version pattern from meta.properties. Your pipeline could look something like this: node \" |sort -r -version-sort|head -1)" You can also solve the task at hand by using a Jenkins 2.0-style Pipeline, which will allow you to checkout the code for components A and B, into a single workspace, and then apply some common build step to them. via the ssh pubkey).Īlternatively you may want to look into the Credentials Binding Plugin, to reuse the Git credentials stored in Jenkins itself. So it must have proper credentials configured, to access the remote Git repository (e.g. The catch is that the shell script will run as the Jenkins daemon user, This will list all the tags, matching "B" version pattern, in the remote "Component B" repository, and save the latest version number in the LATEST variable.Īdd this to your "Execute Shell" step of the "Component A" job,Īnd it should be able to handle version numbers patterns like: 5.3.* |cut -d / -f3|sort -r -version-sort|head -1\ Git ls-remote -tags YOUR_REPOSITORY_URL "$B"\ If you want to support wildcard versions, you can use git ls-remote command to find the latest tag, like that: #B=$(obtain B version from the config file in a usual way) Now each time "Component A" is re-build, a new "Component B" build will get triggered, with the target branch/tag as a build parameter. Using your b.properties file as the source of build parameters. Install a Parameterized Trigger Jenkins plugin, and add a new "Trigger/call builds on other projects" build step to "Component A" job: Step #2Īdd a new "Execute Shell" build step to your "Component A" build, which will extract the "Component B" version from the configuration file in the workspace, and prepare b.properties file with the "Component B" build parameters. Now you should be able to manually trigger "Component B" build, by specifying a proper branch (tag) parameter to it, e.g. Use this parameter as the "Git Plugin" branch specifier: "Component A" (automatically triggered on SCM changes)ĭefine the branch build parameter for "Component B":. One option to achieve what you want is to use the following setup: Merging particular A with B produces full source code for single platform but not every platform may be updated to the latest version of B so it needs to have control over which version of B should be used for built. There may be many Component As - one for each platform, but just single Component B.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |