Automatically create git tag after Jenkins publish

In order to facilitate the rollback of the released version in the project, we automatically create a git tag after each release is completed.

1. Create a Jenkins task named push_tag_demo;

2. Configure "Source Code Management". The special configuration here requires the name of the warehouse, which needs to be used when creating tags later;

3. Select "Git Publisher" in the "Post-build operation" operation to configure the tasks to be executed after publishing.

Notice:

  When configuring Git Publisher, we need to check "Push Only If Build Succeeds", otherwise we will create tags every time the release is successful or failed, which will generate a lot of garbage versions in our warehouse.

4. Click "Add Tag" to configure the information for creating a tag

5. After the configuration is completed, save the configuration information;

6. Click Publish to check the effect;

From the console, we have seen that the tag has been created successfully;

Let's check from the Git background to see if the creation is successful

Summarize:

  In fact, the configuration operation of Jenkins is very simple, but we need to see how we use it in the actual process. It will help us save time if we use it well. If it brings us a lot of confusion, we can replace other tools. The tools are suitable for us the best.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325083855&siteId=291194637