0

I am trying to create a pipeline on jenkins which takes the code from a svn repository , builds it (using MSBuild) , tests it , creates a package from the build artifacts (using Maven) and then commits this package to another svn repository which belongs to another company.

This commit must have a specific commit message format which includes :

1- a short text

2- the url of our repository

3- the revision of some specific dlls what we used to build the solution So as an example :

#Automatic Package Update 
------
src_svn_url = "the source code URL"
src_svn_rev = 33568 , dll1 = 4654 , dll2 = 7657 , ..... 
------

I did some research and found out that it can be done through the pre-commit hooks. Are we able to make this pre-commit hook extract the revision number of different dlls inside my repo and write them automatically in the commit message every time we are committing? The goal for us is to know using which revision of the dlls , we produced the mentioned package.

bahrep
  • 29,961
  • 12
  • 103
  • 150
Ramin B
  • 35
  • 5
  • 1
    `write them automatically in the commit message every time we are committing?` each commit in SVN is recorded with it's revision number so why doing the same svn already does? Second why not using tags in SVN to identify a particular state of development. The revisions you seemed to be using are the revision of particular files last time have been changed that's something different. Are those dll's only in your svn repo or those part of the project you are building? Also I would recommend not to go via svn hook script. – khmarbaise Jan 10 '23 at 11:44
  • The dlls are external dlls that we use inside our project. Then when the build is done , we commit the build artifacts to another company's svn repo (This company provided us with the external dlls). So , as they asked us, when committing the build artifacts , we gotta specify the exact revision of the external dlls that we used to build the code and get the build artifacts. – Ramin B Jan 10 '23 at 12:38
  • 1
    If those dll's are from external from other project that means those dll's are deliveries which means those could be tagged via a svn tag.. (release!) and define such as a dependency eaither in textual form of you could use svn externals to reverence them correctly. – khmarbaise Jan 11 '23 at 10:43

1 Answers1

0

This is not a task of any commit hook script.

You can run the svnversion command in your pipeline to get the revision number and use it to create a commit log message for your new commit into another repository.

For example, you can create the log message in a dedicated file log-message.txt with all the necessary information and then use the svn commit -F log-message.txt command to use the file's contents as the log message.

bahrep
  • 29,961
  • 12
  • 103
  • 150
  • Thank you. My intention is to make the pipeline do this whole process automatically. So , when the build is done , It has to get the revision of some specific dlls , create a text file containing the template in the example of my question and fill up the revision numbers for the dlls , and then do the commit. My problem is automatically creating that text file based on a template and then filling up the revision numbers. – Ramin B Jan 10 '23 at 11:16
  • @RaminB you need to write a script to create the commit log message. Run this script from your pipeline. Then pass the generated text or file into the `svn commit` command so that it's used as the log message. – bahrep Jan 10 '23 at 11:18
  • I can create a python code for that , but If possible I prefer to use a batch file for the script. Do you think that's possible? – Ramin B Jan 10 '23 at 11:23
  • @RaminB Yes, I think that it's possible. I'm afraid that I cannot give you any example, though. However, I think that you should be able to find some examples on the Internet and here on Stack Overflow. – bahrep Jan 10 '23 at 11:25
  • One thing that I forgot to say is that , the package which is sent to another svn repo at the end of the process is labeled as **unversioned**. So basically the svn command for committing it would be **svn import** (Not svn commit). **svn import** does not take the **-F file_name** as a log message (svn commit does). Any idea on how to proceed in this case? – Ramin B Jan 10 '23 at 12:33
  • @RaminB `svn import` supports the `--file FOO` option. The contents of the text file FOO will be used as the log message. I've just tested this and it works. – bahrep Jan 10 '23 at 12:37
  • PS take the comment made by @khmarbaise into account. Using tags is a good idea, I think. – bahrep Jan 10 '23 at 12:38