使用POST COMMIT钩子在SVN存储库上提交代码时,Jenkins作业自动触发

编程入门 行业动态 更新时间:2024-10-26 20:22:11
本文介绍了使用POST COMMIT钩子在SVN存储库上提交代码时,Jenkins作业自动触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Jenkins,docker和Ansible实现CI/CD管道.我正在将SVN代码存储库用于我的版本控制系统.对于部署和SVN代码存储库,我使用的是AWS EC2.部署和代码存储库位于单独的VM中.

I am trying to implement CI/CD pipeline using Jenkins , docker and Ansible. I am using SVN code repository for my version control system. For deployment and SVN code repo, I am using AWS EC2. Deployment and code repo is in separate VM.

我的要求

当我将代码提交到SVN存储库中时,我需要触发一个Jenkins Job.该工作将被称为ansible playbook,稍后将构建项目,构建Docker映像并将其部署到EC2中.因此,对于我的SVN代码存储库的任何更改,我需要构建Jenkins作业.

When I am committing my code into SVN repository , I need to trigger one Jenkins Job. That job will call a ansible playbook.Later it will build project, build Docker image and deploy into EC2. So for any change to my SVN code repository, I need to build Jenkins job.

我当前的尝试

我在$ repo/hooks文件夹下的post-commit.tmpl文件中添加了以下脚本.

I added the following script in post-commit.tmpl file under $repo/hooks folder.

REPOS="$1" REV="$2" UUID=`svnlook uuid $REPOS` /usr/bin/wget \ --header "Content-Type:text/plain;charset=UTF-8" \ --post-data "`svnlook changed --revision $REV $REPOS`" \ --output-document "-" \ --timeout=2 \ server/subversion/${UUID}/notifyCommit?rev=$REV

以下是屏幕截图

并选中"Jenkins Job中的投票SCM选项":

And checked the "Poll SCM option in Jenkins Job":

注意::我不是要从回购中抽出分钟/小时/周的时间表.取而代之的是,我正在寻找代码更改的时间,然后我需要构建Jenkins项目.所以我没有添加任何时间表.

NB: I am not looking minute/hours/week schedule to pull from repo. Instead of that, I am looking when there is a code change, then I need to build Jenkins project. So I did not add any schedule.

但是我仍然没有得到Jenkins的最新代码.如何找出与我的配置有关的问题?

But still I am not getting the latest code in Jenkins. How can I find out the issue related with my configuration?

已更新的post-commit.tmpl文件

推荐答案

我做了很多尝试,通过使用答案中的指导来解决此问题.最终,我得到了我所面临的实际问题.我在文件"post-commit.tmpl"中添加了提交后脚本.创建我的SVN信息库时默认获得此文件.无需添加"post-commit.tmpl",只需创建文件"post-commit"即可.它解决了我的问题.

I made lot attempt to resolve this problem by using guidance from answers. Finally I got the actual issue that I was facing. I added the post-commit script in the file "post-commit.tmpl". This file defaulty I got when I created my SVN repository. Instead of adding the "post-commit.tmpl" need to create file just "post-commit". It resolved my problem.

更多推荐

使用POST COMMIT钩子在SVN存储库上提交代码时,Jenkins作业自动触发

本文发布于:2023-11-24 05:10:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624073.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:钩子   作业   代码   COMMIT   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!