Run inno script compiler in gitlab cicd - gitlab

I enable CI/CD in gitlab.
I would like to, in the build job, compile a setup made with inno setup. This is yaml gitlab configuration related to build job:
build:
stage: build
script:
- echo building project...
- C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild /target:Build /property:config=Release /verbosity:q Project1.dproj /p:DCC_BuildAllUnits=true /p:"Platform=Win32"
- iscc "path/file.iss"
artifacts:
name: "test"
paths:
- Win32\Release\Project1.exe
But, when i execute the pipeline I got this error:
ISCC : Termine 'ISCC' non riconosciuto come nome di cmdlet, funzione, programma eseguibile o file script. Controllare
l'ortografia del nome o verificare che il percorso sia incluso e corretto, quindi riprovare.
I launch this pipeline in my windows machine and I already add environment variables in the system.
Anyone has idea why is wrong?
Thanks in advance

You probably need to specify the full path to your InnoSetup installation folder, or add the folder to the PATH in System Environment variables.

Related

GitLab CI and MsBuild - Local CMD Works; GitLab Runner Doesn't?

This is really bizarre, but I'm sure I'm misunderstanding or missing something simple.
Whilst RDP'd to the Windows GitLab runner, the following command works without issue:
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" C:\GitLab-Runner\builds\rS1z3GJ3\0\folder1\client\build\ClientWebsite.msbuild /t:BuildAndPackage /nowarn:CS0618 /p:IisWebAppName=client /p:IncludeSetAclProviderOnDestination=False /p:ProductVersion=1
Going by the MSBuild file, the build files are then created under C:\GitLab-Runner\builds\rS1z3GJ3\0\folder1\client\deploy_files.
But when I run the exact same command in via the gitlab-ci.yml file, the deployment files aren't generated.
The output from the GitLab job is:
CMD.EXE "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" C:\GitLab-Runner\builds\rS1z3GJ3\0\folder1\client\build\ClientWebsite.msbuild /t:BuildAndPackage /nowarn:CS0618 /p:IisWebAppName=client /p:IncludeSetAclProviderOnDestination=False /p:ProductVersion=1
Microsoft Windows [Version 10.0.17763.2628]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\GitLab-Runner\builds\rS1z3GJ3\0\folder1\client>
Cleaning up project directory and file based variables 00:00 Job succeeded
I thought perhaps this was an issue with the user the GitLab Runner service was set to run as, but even when trying with a local admin user it still doesn't work.
I suspected it was an issue with the cleaning up of the project directory, but even when setting the deployment files to be exported to a separate folder on another drive they still don't appear.
What could I be doing wrong?
Any help with this would be greatly appreciated.
EDIT:
GitLab Runner Config:
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "buildserver01"
url = "https://gitlab.company.co.uk"
token = "rS1z3GJ392utu-J-CkeM"
executor = "shell"
shell = "powershell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
GitLab-Ci.Yml File:
variables:
SERVICE_NAME: "client"
NODE_VERSION: "14.15.3"
stages:
- build $SERVICE_NAME package with MSBuild.exe
build_package:
stage: build $SERVICE_NAME package with MSBuild.exe
tags:
- client
script:
- echo "Installing NodeJS environment $NODE_VERSION if it's not already installed."
- nvm install $NODE_VERSION
- echo "Selecting NodeJS environment $NODE_VERSION using NVM"
- nvm use $NODE_VERSION
- echo "Creating the Web Deploy Package"
- CMD.EXE "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" C:\GitLab-Runner\builds\rS1z3GJ3\0\folder1\client\build\clientWebsite.msbuild /t:BuildAndPackage /nowarn:CS0618 /p:IisWebAppName=client /p:IncludeSetAclProviderOnDestination=False /p:ProductVersion=1
Thanks to GitLab Support, this has now been resolved.
They advised to completely remove the 'CMD.EXE' command and instead run MSBuild directly via PowerShell:
'& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" $CI_PROJECT_DIR\build\ClientWebsite.msbuild /t:BuildAndPackage /nowarn:CS0618 /p:IisWebAppName=Client /p:IncludeSetAclProviderOnDestination=False /p:ProductVersion=1'

How to run Specflow test cases in pipeline of Gitlab for CI/CD implementaiton

I want to implement CI/CD so that whenever dev team commits any changes in their build then my whole automation suite runs before build and deployment.
I have yml file in GitLab and automated test case scripts in Visual Studio (Specflow framework in C#).
Please find below yml file:
demo_job_1:
stage: test
tags:
- win
script:
- echo "Test 1 started"
- '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\vstest.console.exe /ProjName.dll"'
- '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\MSTest /testcontainer:D:\Users\username\source\repos\Project\ProjName\bin\Debug\netcoreapp3.1\ProjName.dll"'
- "D:\Users\username\source\repos\Project\ProjName\ProjName.sln\Test\TestFeature1.csproj"'
But my job is passing without actually executing any of the test cases from the project
Folder structure in Visual studio:
I tried to do many changes in the path but none worked. Am I entering the wrong path? Can anyone please help me with this? If the yml file is completely wrong then can someone please guide me in the same? Thanks in advance!!! :)
P.S: I had validated yml before committing it and ymlvalidator showed it as the correct yml file.
demo_job_1:
stage: test
tags:
- tags
script:
- Root dir location path
- 'dotnet restore <path to the ProjName.sln>'
- 'dotnet msbuild <path to the ProjName.sln>'
- 'dotnet test <path to the ProjName.sln>'
Hope this helps others too!!!

I have a yaml file.I need to trigger everyday with website datas how can I do?

I have a yaml file with build stage, but I need a deploy stage for trigger everyday at 16.00 with website (on the internet) datas. How can I write a valid deploy stage?
//gitlab.ci.yaml file and build stage. I need a deploy stage to use trigger as a service.
variables:
NUGET_PATH: 'C:\Tools\Nuget\nuget.exe'
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64\msbuild.exe'
stages:
- build
before_script:
- "cd Source"
build_job:
stage: build
only:
- master
script:
- '& "$env:NUGET_PATH" restore'
- '& "$env:MSBUILD_PATH" Textbox_ComboBox.sln /nologo /t:Rebuild /p:Configuration=Debug'
I expect the everyday at 16.00 datas are updated with on the internet website datas how can I fix the yaml file (taking datas on website is important).
Using this tutorial you should be able to achieve what you want.
To answer more specifically to your question how to send data to Gitlab, you need to configure a Gitlab runner that will run your jobs and send the results back to GitLab. You can follow the official documentation right here.
After the Gitlab runner if installed, you should be able to see it in Gitlab, in Settings > CI/CD.
Then configure your schedule following the official documentation here and using your gitlab-ci.yaml file.

Azure DevOps pipeline build locally with YAML

how can I simulate the build process of Azure Devops pipeline on the local machine before pushing it to branch to test the possible errors.
the solution gets build locally correct with no errors and warnings. also from the VS command line MSBuild builds the solution with no errors but on some push tries the pipeline build throws many errors mostly related to preprocessor defenition and precompiled header.
I wanted to know how can test the same process locally on my machine without pushing to repo.
azure-pipelines.yml
-------------------
pool:
vmImage: 'vs2017-win2016'
steps:
- task: MSBuild#1
displayName: 'Build solution'
inputs:
platform: 'Win32'
configuration: 'release'
solution: 'mysolution.sln'
- task: VSTest#2
displayName: 'Run Test'
inputs:
platform: 'Win32'
Configuration: 'release'
testAssemblyVer2: |
**\*.Test.dll
!**\*TestAdapter.dll
!**\obj\**
runSettingsFile: project.Test/test.runsettings
codeCoverageEnabled: true
If you are using a git repsotiory you can create another branch and make a pull request. As long as the pull request is not set to auto complete the code will not get committed to the repository.
If you are using a TFVC respository you can setup a gated build that is configured to fail. The pipeline should be a copy of your original pipeline but add a PowerShell task at the end of the build pipeline that throws a terminating error. Be sure to setup this gated build on a separate branch so it does not block normal development.
Write-Error "Fail here" -ErrorAction 'Stop'
You can now make pull requests or trigger a gated build without the code actually being commited.
You can use AzurePipelinesPS to install an agent on your local machine with the Install-APAgent command if you need another agent.
I'm only a few hours into to development with Azure, but I think I found a solution that would work for you. I happen to already have the solution in place. Use gradle, then the default YML just runs gradle and you don't have to worry too much about it after the first run. In the gradle file you could also spin up a docker image if you want and build on that.
The issue you have is most likely related to the difference between your local environment and the one on build agent where this YAML pipeline execute the build. Testing it locally (even if it would be possible) will not help as it will be executed in your environment, where you know already that every component required for the successful build are already installed. On the other side on the environment where build agent is running the build there seems to be missed components (or different versions) which cause your build to fail. Try to compare list of installed components and environment variables (like PATH) on your local machine and on build agent - there might be some difference between them.

Execute a script before the branch is deleted in GitLab-CI

GitLab-CI executes the stop-environment script in dynamic environments after the branch has been deleted. This effectively forces you to put all the teardown logic into the .gitlab-ci.yml instead of a script that .gitlab-ci.yml just calls.
Does anyone know a workaround for this? I have a shell script that removes the deployment. This script is part of the repository and can also be called locally (i.e. not onli in an CI environment). I want GitLab-CI to call this script when removing a dynamic environment but it's obviously not there anymore when the branch has been deleted. I also cannot put this script to the artifacts as it is generated before the build by a configure script and contains secrets. It would be great if one could execute the teardown script before the branch is deleted.
Here's a relevant excerpt from the .gitlab-ci.yml
deploy_dynamic_staging:
stage: deploy
variables:
SERVICE_NAME: foo-service-$CI_BUILD_REF_SLUG
script:
- ./configure
- make deploy.staging
environment:
name: staging/$CI_BUILD_REF_SLUG
on_stop: stop_dynamic_staging
except:
- master
stop_dynamic_staging:
stage: deploy
variables:
GIT_STRATEGY: none
script:
- make teardown # <- this fails
when: manual
environment:
name: staging/$CI_BUILD_REF_SLUG
action: stop
Probably not ideal, but you can curl the script using the gitlab API before running it:
curl \
-X GET https://gitlab.example. com/raw/master/script.sh\
-H 'PRIVATE-TOKEN: ${GITLAB_TOKEN}' > script.sh
GitLab-CI executes the stop-environment script in dynamic environments after the branch has been deleted.
That includes:
An on_stop action, if defined, is executed.
With GitLab 15.1 (June 2022), you can skip that on_top action:
Force stop an environment
In 15.1, we added a force option to the stop environment API call.
This allows you to delete an active environment without running the specified on_stop jobs in cases where running these defined actions is not desired.
See Documentation and Issue.

Resources