Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand and use Jenkins-X UpdateBot

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to understand and use Jenkins-X UpdateBot. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Jenkins-X UpdateBot is a tool for automatically updating the version of dependencies in the project source code. Suppose you are building two projects, An and B, which use An as a dependency. The release process of A can use UpdateBot to update the source of Project B to use the new version of A. Using UpdateBot in pull request, you can test and check for changes or automatically merge changes.

In Jenkins-X platform, UpdateBot is automatically displayed and invoked by the UpdateBot command in Jenkinsfile. But UpdateBot can also be used outside of Jenkins-X, and running it alone can help you understand what it can do and test version replacements. So let's try it with a simple test project.

Configuration demonstration

UpdateBot can be versioned for a variety of different file types-we won't test them all here, but we want a project to have multiple features. Therefore, we can use the JHipster sample app sample application because it has Maven pom.xml,npm package.json and Dockerfile. We will run UpdateBot on it to see what UpdateBot can replace in these resource files.

We can download UpdateBot jar file (v1.1.31) and set a simple UpdateBot configuration file that points to the GitHub repository for the project to be updated:

Github: organisations:-name: ryandawsonuk repositories:-name: jhipster-sample-app useSinglePullRequest: true

The useSinglePullRequest tag means that we will create a PR that contains all the changes we have made. But we won't actually make any changes-we'll run it locally so we don't need GitHub write access to the repository. By setting environment variables, we can run without pushing to GitHub:

Export UPDATEBOT_DRY_RUN=true

Then, we still need to set the git credentials using UPDATEBOT_GITHUB_USER and other environment variables of UPDATEBOT_GITHUB_PASSWORD (Token).

We can then run some UpdateBot commands and see what has been replaced from the project cloned by Git. To do this, we can use a demo project with preconfigured scripts on GitHub.

Run the demo

First, the script updates the maven pom.xml, requiring a change in the Spring Boot version:

Java-jar updatebot-1.1.31.jar push-version-- kind maven org.springframework.boot:spring-boot-starter-data-jpa 2.1.0.RELEASE

Then check the changes and output the git diff, and we can see the following results:

So the version was replaced. Note that it is replaced in the property referenced by the dependency, in which case pom.xml has this version in the property. UpdateBot can also be used for changes made directly in dependencies or parents or plug-ins.

The change to package.json is to change the ngx-cookie version to 2.0.2:

Java-jar updatebot-1.1.31.jar push-version-- kind npm ngx-cookie 2.0.2

This is exactly what we expect:

The change to Dockerfile is to change the openjdk version / label to jdk8:

Java-jar updatebot-1.1.31.jar push-version-- kind docker openjdk 8-jdk

It shows that we can grab it. Dockerfile actually uses two different openjdk images, each with a different label, and this command replaces the two images:

I didn't think about this before running the command, so here I need to determine what I really want to replace.

Actual operation

If we run without the dry-run tag, we will create a real pull request, provided we have the right to create it.

UpdateBot has the ability to automatically merge pull request, such as polling GitHub to check PR status and merge to see if everything is fine (the command is updatebot update-loop). However, GitHub does impose rate limits on these requests, so UpdateBot can also add their approval to PR so that they can be merged through tools that integrate directly with GitHub. This may work well when automatic merging is done using tools such as prow or mergify.

UpdateBot can try to infer changes to be made as part of the commit trigger pipeline only by using updatebot push instead of updatebot push-version with explicit parameters. However, usually the pipe job will have access to the version to be pushed, and push version makes the changes clearer and easier to track.

This example uses a single UpdateBot YAML file to push a set of dependencies / versions to a downstream project. The YAML file also supports pushing a set of changes to multiple downstream repositories. UpdateBot pushes all the replacements it can make so that each downstream repository gets all the changes that apply to it.

For example, when building a Maven project without snapshots, UpdateBot can be used to propagate versions in CI/CD settings. However, as we have seen, it is not limited to Maven, but can also make a series of changes to projects that produce different types of artifacts.

The above is the editor for you to share how to understand and use Jenkins-X UpdateBot, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report