简体   繁体   English

Jenkins内部版本号问题

[英]Jenkins build number issue

I have posted the question once but I think it was incomplete information.. Here is my question..I am new to jenkins. 我已经发布了一个问题,但是我认为这是不完整的信息。这是我的问题。 I am running a free-style project in jenkins. 我正在詹金斯(Jenkins)运行一个自由风格的项目。 Previously I was using BuildForge for all my builds. 以前,我在所有构建中都使用BuildForge。

The issue is, there is a Properties file say abc.properties file. 问题是,有一个名为abc.properties的属性文件。 It contains 它包含

Buildnumber=0 内部编号= 0

Previously I was using an xml and BTM file through which "BuildNumber" gets in sync with current build number. 以前,我使用的是xml和BTM文件,通过该文件“ BuildNumber”与当前内部版本号同步。 The code of BTM file is BTM文件的代码是

echo build.number=%ABCBuild redirect to: c:%BUILDBASEDIR\\myfile\\ABCbuild.number echo build.number=%ABCBuild echo build.number =%ABCBuild重定向到:c:%BUILDBASEDIR \\ myfile \\ ABCbuild.number echo build.number =%ABCBuild

c:%BUILDBASEDIR\\myfile\\ABCbuild.number echo build.number=%ABCBuild redirect to: c:%BUILDBASEDIR\\myfile\\GUIbuild.number echo build.number=%ABCBuild > c:%BUILDBASEDIR\\myfile\\GUIbuild.number echo collector.build.number=%1 redirect to: c:%BUILDBASEDIR\\myfile\\filebuild.properties echo collector.build.number=%1 > c:%BUILDBASEDIR\\myfile\\filebuild.properties echo collector.build.type=indiv append to: c:%BUILDBASEDIR\\myfile\\filebuild.properties echo collector.build.type=indiv >> c:%BUILDBASEDIR\\myfile\\filebuild.properties echo. c:%BUILDBASEDIR \\ myfile \\ ABCbuild.number echo build.number =%ABCBuild重定向到:c:%BUILDBASEDIR \\ myfile \\ GUIbuild.number echo build.number =%ABCBuild> c:%BUILDBASEDIR \\ myfile \\ GUIbuild.number echo收集器.build.number =%1重定向到:c:%BUILDBASEDIR \\ myfile \\ filebuild.properties回声收集器.build.number =%1> c:%BUILDBASEDIR \\ myfile \\ filebuild.properties回声收集器.build.type = indiv附加到:c:%BUILDBASEDIR \\ myfile \\ filebuild.properties回显收集器。build.type= indiv >> c:%BUILDBASEDIR \\ myfile \\ filebuild.properties回显。

And it create a zip file in which the abc.properties file contains the build number. 然后创建一个zip文件,其中abc.properties文件包含内部版本号。

Steps involved in xml file are xml文件中涉及的步骤是

Prepare: 准备:

safe-clean: 安全清洁:

create-file: 创建文件:

create-current-file-qpack: 创建当前文件qpack:

create-file-qpack: 创建文件qpack:

build-file-qpack: 构建文件qpack:

create-current-file-rpack: 创建当前文件rpack:

create-file-rpack: 创建文件rpack:

build-file-rpack: 构建文件rpack:

prepare-anystudio: 准备任何工作室:

fill-file-props: 填充文件道具:

create-current-file: 创建当前文件:

    <target name="create-current-file" depends="prepare-anystudio,fill-file-props">
    <property name="file.name" value="${file.name}"/>
    <property name="file.version" value="${file.version}"/>
    <property name="file.path" value="${file.path}"/>

    <echo message="Building file ${file.name} version ${file.version}......."/>

    <delete dir="${cur.dirname}/${dir.final}/files/${file.name}"/>
    <echo message="-sourcefiles ${file.path}/${file.name} -output            ${cur.dirname}/${dir.final}"/>
    <java dir="${cur.dirname}/${dir.filestudio.exec}"
          classname="com.comp.cas.ucf.configtool.DistributionUtil" failonerror="true"     fork="yes">
        <classpath refid="classpath.studio"/>

Build Steps involved in jenkins are 詹金斯涉及的构建步骤是

Wipe-Out the workspace 擦除工作空间

Perforce Sync Perforce同步

Run Batch Command 运行批处理命令

Invoke Ant (Steps mentioned earlier) 调用Ant(前面提到的步骤)

Build Successful 建立成功

Run Post Build Script (Batch) 运行后生成脚本(批处理)

makdir 马克迪尔

creates zip 创建拉链

I have written the batch file to replace the current build number. 我已经写了批处理文件以替换当前的内部版本号。 But after the ANT runs Its always a Game Over situation because it don't updates the file. 但是在ANT运行“总是游戏结束”情况后,因为它不会更新文件。 The Batch script is 批处理脚本是

Batch script I am using is. 我正在使用的批处理脚本是。

 @echo off 

call :FindReplace "Buildnumber=0" "Buildnumber=%BUILD_NUMBER%" abc.properties exit /b 调用:FindReplace“ Buildnumber = 0”“ Buildnumber =%BUILD_NUMBER%” abc.properties退出/ b

 :FindReplace <Buildnumber=0> <Buildnumber=111> <collector.properties> set tmp="%temp%\\tmp.txt" If not exist %temp%\\_.vbs call :MakeReplace for /f "tokens=*" %%a in ('dir "%3" /s /b /ad /on') do ( for /f "usebackq" %%b in (`Findstr /mic:"%~1" "%%a"`) do ( echo(&Echo Replacing "%~1" with "%~2" in file %%~nxa <%%a cscript //nologo %temp%\\_.vbs "%~1" "%~2">%tmp% if exist %tmp% move /Y %tmp% "%%~dpnxa">nul ) ) del %temp%\\_.vbs exit /b :MakeReplace 

%temp%_.vbs echo with Wscript %temp%_。vbs使用Wscript回显

%temp%_.vbs echo set args=.arguments %temp%_.vbs echo .StdOut.Write _ %temp%_.vbs echo Replace(.StdIn.ReadAll,args(0),args(1),1,-1,1) %temp%_.vbs echo end with. %temp%_。vbs echo set args = .arguments%temp%_。vbs echo .StdOut.Write _%temp%_。vbs echo Replace(.StdIn.ReadAll,args(0),args(1),1, -1,1)%temp%_。vbs回显结尾。

Now Please can someone tell me.. How I can put the buildnumber in the zip file. 现在请有人告诉我。如何将内部版本号放入zip文件中。 Yeah the zip file is created at a local repo path and not in the workspace. 是的,该zip文件是在本地回购路径而非工作空间中创建的。

I am using Perforce for all my code check-in and sync. 我正在使用Perforce进行所有代码签入和同步。

I think the "Create-current-file" is filling my file and properties file as well. 我认为“创建当前文件”也在填充我的文件和属性文件。

Please help. 请帮忙。 I want to use the similar logic in jenkins so that I can have the build number in the zip file as well. 我想在詹金斯中使用类似的逻辑,以便我也可以在zip文件中拥有内部版本号。 The script above is really helpful It changes the build number in the workspace but not effective as after the ANT INVOKES the game changes and I got the buildNumber as 0 because the buildnumber in perforce is always 0. 上面的脚本确实很有帮助。它更改了工作区中的内部版本号,但没有有效,因为在ANT INVOKES游戏更改后,我将内部版本号设为0,因为perforce中的内部版本号始终为0。

Note: ANT get its file from the workspace where P4 has store it. 注意:ANT从P4存储文件的工作区中获取文件。

What needs to be done. 需要做什么。 Please help, I already spend three days on it. 请帮助,我已经花了三天时间。

You don't need any magic or scripting assests to get build number, if you use this value within one project. 如果在一个项目中使用此值,则不需要任何魔术或脚本帮助即可获得内部版本号。 ;) ;)

Each (and any kind of jenkins supported project types) job ( IMHO ) has ability to use Environment Variables. 每个(以及任何支持jenkins的项目类型)作业(IMHO)都可以使用环境变量。

See this link: http:// <your_build_server_name> /env-vars.html/? 看到此链接:http:// <your_build_server_name> /env-vars.html/? as example. 例如。

As long as you use SCM and Build SCripting ( Maven, Ant, ? ), you can freely use them. 只要您使用SCM和Build Scripting(Maven,Ant 、?),就可以自由使用它们。 If called from windows batch, access them using %%, not ${} syntax. 如果从Windows批处理中调用,请使用%%而非$ {}语法访问它们。 ;) ;)

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

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