From dda3c718437a49b8673be351dcfe55b96cfab771 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli (MBA)" Date: Thu, 26 Jan 2023 21:53:13 +0100 Subject: [PATCH] test yaml (da verificare) --- .gitlab-ci.yml | 154 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..25f19f2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,154 @@ +variables: + VERS_MAIN: '1.0' + NEW_REL: '' + APP_NAME: 'Egw.Core.Razor.Comp' + SOL_NAME: 'Egw.Core.Razor.Comp' + +# helper x fix pacchetti nuget da repo locale nexus.steamware.net +.nuget-fix: &nuget-fix + - | + echo "esecuzione Nuget FIX steps" + dotnet nuget list source + $hasSource = dotnet nuget list source | Select-String -Pattern "Steamware Nexus Proxy" + if (! [String]::IsNullOrWhiteSpace($hasSource)) { + dotnet nuget remove source "`"Steamware Nexus Proxy`"" + } + $hasSource = dotnet nuget list source | Select-String -Pattern "Steamware Nexus" + if (! [String]::IsNullOrWhiteSpace($hasSource)) { + dotnet nuget remove source "`"Steamware Nexus`"" + } + $hasSource = dotnet nuget list source | Select-String -Pattern "nexus-proxy-v3" + if (! [String]::IsNullOrWhiteSpace($hasSource)) { + dotnet nuget remove source nexus-proxy-v3 + } + dotnet nuget add source https://nexus.steamware.net/repository/nuget-group-3/index.json -n "Steamware Nexus" -u nugetUser -p viaDante16 --store-password-in-clear-text + echo "Steamware Nexus Source added" + +# helper creazione hash files x IIS +.hashBuild: &hashBuild + - | + $Target = $env:APP_NAME + "\bin\publish\" + $env:APP_NAME + ".zip" + $MD5 = Get-FileHash $Target -Algorithm MD5 + $SHA1 = Get-FileHash $Target -Algorithm SHA1 + New-Item $Target".md5" + New-Item $Target".sha1" + $MD5.Hash | Set-Content -Path $Target".md5" + $SHA1.Hash | Set-Content -Path $Target".sha1" + + echo "Created HASH files for $Target" + +# helper x send su NEXUS x pack +.nexusUpload: &nexusUpload + - | + Set-Alias mCurl C:\Windows\system32\curl.exe + $fileVers = $env:APP_NAME + "\Resources\VersNum.txt" + $VersNumb = Get-Content $fileVers + echo "Curr Version: $VersNumb" + if($CI_COMMIT_BRANCH -eq "master") + { + $version = "stable" + } + else + { + $version = "unstable" + } + $File2Send = Get-ChildItem($env:APP_NAME + "\bin\publish\*") + ForEach ($File in $File2Send) { + $FileName = Split-Path $File -leaf + mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName + mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/ARCHIVE/$VersNumb/$FileName + } + mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "$env:APP_NAME\Resources\manifest.xml" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/manifest.xml + mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "$env:APP_NAME\Resources\ChangeLog.html" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/ChangeLog.html + +stages: + - build + - staging + - deploy + - release + + +# ---------- BUILD ---------- +Egw.Core.Razor.Comp:build: + stage: build + tags: + - win + variables: + APP_NAME: Egw.Core.Razor.Comp + SOL_NAME: Egw.Core.Razor.Comp + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + +# ---------- STAGING ---------- +Egw.Core.Razor.Comp:staging: + stage: staging + tags: + - win + variables: + APP_NAME: Egw.Core.Razor.Comp + SOL_NAME: Egw.Core.Razor.Comp + only: + - develop + needs: ["Egw.Core.Razor.Comp:build"] + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + +# ---------- DEPLOY ---------- +Egw.Core.Razor.Comp:deploy: + stage: deploy + tags: + - win + # environment: + # name: production + # url: https://iis03.egalware.com/GPW/CORE.Smart + variables: + APP_NAME: Egw.Core.Razor.Comp + SOL_NAME: Egw.Core.Razor.Comp + only: + - main + needs: ["Egw.Core.Razor.Comp:build"] + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + # IIS 02 + - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + # IIS 03 + - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + +# ---------- RELEASE ---------- +Egw.Core.Razor.Comp:release: + stage: release + tags: + - win + variables: + APP_NAME: Egw.Core.Razor.Comp + SOL_NAME: Egw.Core.Razor.Comp + only: + - main + except: + - branches + needs: ["Egw.Core.Razor.Comp:build"] + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + artifacts: + paths: + - publish/ + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet + # qui il deploy su nexus... + - *hashBuild + - *nexusUpload + # script: + # - dotnet publish -c Release -o ./publish GPW.Egw.Core.Razor.Comp/GPW.Egw.Core.Razor.Comp.csproj + \ No newline at end of file