简体   繁体   English

Jenkins触发作业,无需更改git

[英]Jenkins triggers jobs without git changes

We have a jenkins server running that builds the respective jobs on a docker container using the docker jenkins plugin : 我们有一个运行的jenkins服务器,它使用docker jenkins插件docker容器上构建各自的作业:

Each job checks every N minutes whether changes on git have been made. 每个作业每N分钟检查一次git是否已更改。 In case of any change a docker container is created and the project is successfully build on that container. 如果进行任何更改,则会创建一个docker容器,并且将在该容器上成功构建项目。 Finally, after building, the docker container is going to shutdown. 最后,在构建之后,docker容器将关闭。

The problem : Jenkins triggers all N minutes a new build without any changes on git . 问题 :Jenkins会在N分钟内触发一个新构建, 而git却没有任何变化 The problem might be that there are no workspaces available to check for changes since the docker container is not available anymore. 问题可能是由于docker容器不再可用,因此没有可用的工作空间来检查更改。

Any idea how to solve that problem? 任何想法如何解决该问题?

Edit: Our jenkins server isn't accessible from public net. 编辑:无法从公共网络访问我们的jenkins服务器。

Edit: Workaround: Create a new job that definitely clone the project into a workspace (on the jenkins master) and trigger some children jobs in case on a change. 编辑:解决方法:创建一个新作业,该作业肯定会将项目克隆到工作区中(在jenkins主数据库上),并在发生更改时触发一些子作业。 The difference here is that master keeps the workspace and is therefore able to check for differences whereas the workspace of the docker container is deleted once the container is closed. 此处的区别在于,master保留了工作空间,因此能够检查是否存在差异,而Docker容器的工作空间在容器关闭后即被删除。

why to check for every N minutes for git changes. 为什么每隔N分钟检查一次git变化。 the Best thing is to make Jenkins build after every git change. 最好的办法是在每次git更改后使Jenkins生成。 1. check poll scm option, but do not enter anything in schedule. 1.检查poll scm选项,但不要按计划输入任何内容。 在此处输入图片说明 2. Now go to git repository folder and go into hooks folder, there you will find hooks samples, use post-receive.sample, rename it to post-receive , make it as executable, then in the file write 2.现在转到git repository文件夹并进入hooks文件夹,您将在其中找到hooks示例,使用post-receive.sample,将其重命名为post-receive,使其可执行,然后在文件中写入

#!/bin/bash

curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository

Then save it. 然后保存。 Now Jenkins build after every Git change. 现在,每次Git更改后,Jenkins都会构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM