2

여기 내가 달성하려고하는 것입니다. 나는 현재 허드슨 빌드를 사용하여 원격 컴퓨터에서 나를 빌드한다. 현재 솔루션을 열고 두 파일의 [assembly : AssemblyVersion ("1.2.6.190")] 숫자를 수동으로 업데이트 한 다음 허드슨을 통해 빌드를 실행하기 전에 SVN에 변경 사항을 커밋해야합니다. (hudson 작업은 지금 빌드하지 않으면 실행되도록 설정되지 않았습니다.)허드슨 빌드로 빌드 번호 증분

허드슨이 빌드를 수행 할 때마다 마지막 숫자 만 자동으로 증가시키는 방법을 찾고 싶습니다.

1 씩 증가 시키길 원합니다 (타임 스탬프가 없거나 비슷한 것은 아닙니다).

어떤 아이디어 또는 다른 주시면 감사하겠습니다 도움이 될 수 있습니다 재료 =)

감사에 대한 링크,

토비

답변

2

.

여기에 "호"로 대답 한 번 봐 - How can I auto increment the C# assembly version via our CI platform (Hudson)?

그것은 아니에요 허용 대답하지만 그것은 완벽하게 작동대로해야한다.

+0

문제가 해결되면 답변을 수락으로 표시하십시오. 이 방법으로 다른 사람들은 해결 된 것을 알게 될 것입니다 – ghostJago

+0

Nick Nieslanik의 답변은 Hudson/Jenkins에서 PowerShell 플러그인을 사용하지 않고도 (PowerShell 프로세스를 호출하는 MSBUild Exec을 사용하여) 완벽하게 작동한다고 덧붙이고 싶습니다. – gimpf

5

나는 젠킨스의 PowerShell을 플러그인을 사용하여 모든 파일을 찾을 PowerShell을 사용하여 패턴 (예 : AssemblyInfo. *)과 일치하는 파일을 읽은 다음 파일을 읽고 PowerShell의 기본 정규 표현식 기능 (-match 및 -replace 연산)을 사용하여 AssemblyVersion 속성을 찾아 바꾸고 마지막 8 진수를 현재로 변경합니다 젠킨스가 번호를 만듭니다. 난 단지 계정으로 내가 좋은 해결책에 대한 링크를 게시 할 것이라고 생각 허드슨을 사용하여 내 요구 사항을 고려하지 않은 답을 가지고 있기 때문에

function assign-build-number 
{ 
    #get the build number form Jenkins env var 
    if(!(Test-Path env:\BUILD_NUMBER)) 
    { 
     return 
    } 

    #set the line pattern for matching 
    $linePattern = 'AssemblyFileVersion' 
    #get all assemlby info files 
    $assemblyInfos = gci -path $env:ENLISTROOT -include AssemblyInfo.cs -Recurse 

    #foreach one, read it, find the line, replace the value and write out to temp 
    $assemblyInfos | foreach-object -process { 
     $file = $_ 
     write-host -ForegroundColor Green "- Updating build number in $file" 
     if(test-path "$file.tmp" -PathType Leaf) 
     { 
      remove-item "$file.tmp" 
     } 
     get-content $file | foreach-object -process { 
      $line = $_ 
      if($line -match $linePattern) 
      { 
       #replace the last digit in the file version to match this build number. 
       $line = $line -replace '\d"', "$env:BUILD_NUMBER`"" 
      } 

      $line | add-content "$file.tmp" 

     } 
     #replace the old file with the new one 
     remove-item $file 
     rename-item "$file.tmp" $file -Force -Confirm:$false 
    } 
}