我正在尝试使用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作业自动触发
发布评论