How to set assembly version to Jenkins build number?

后端 未结 3 1708
遇见更好的自我
遇见更好的自我 2020-12-30 14:44

I am using \"Change Assembly Version\" plug-in in Jenkins to update all AssemblyInfo.cs files of my ASP.NET MVC project to apply version number during build process. If I se

3条回答
  •  天涯浪人
    2020-12-30 14:55

    For others looking to update just 1 number of the version number but keep the rest of the existing version numbers you can set up the "Change Assembly Version" plug-in as follows:

    Assembly Version: $BUILD_NUMBER
    FileName: /Properties/AssemblyInfo.cs
    RegexPattern: Assembly(\w*)Version\("(\d+).(\d+).(\d+).(\d+)"\)
    ReplacementPattern: Assembly$1Version("$2.$3.%s")

    This will keep the existing, first 2 numbers already contained in the Assembly???Version settings and set the 3rd version number to the current Jenkins build number.

    Example

    AssemblyInfo.cs contains:

    [assembly: AssemblyVersion("1.40.0.0")]
    [assembly: AssemblyFileVersion("1.40.0.0")]
    

    If the Jenkins build number is 103, then after the above settings are used by the Change Assembly Version plugin the AssemblyInfo.cs will contain:

    [assembly: AssemblyVersion("1.40.103.0")]
    [assembly: AssemblyFileVersion("1.40.103.0")]
    

    Note

    If you are using subversion (and likely other source control systems) and are using the "Check-out Strategy" of "Use SVN update as much as possible" you will have to change it to "Use SVN update as much as possible with svn revert before update" to ensure that the modified AssemblyInfo.cs file is reset for the next build.

提交回复
热议问题