I started using Gitlab CI/CD and it is my yml file:
variables:
EXE_LOCAL_TEMP_FOLDER: 'c:\TMP'
DEPLOY_FOLDER: 'c:\MyProject_Release'
stages:
- build
- deploy
build:
stage: build
script:
- nuget restore
- msbuild MySolution.sln /t:Build /p:Configuration=Release
- xcopy /y MyProject\bin\Release\*.* $EXE_LOCAL_TEMP_FOLDER\
deploy:
stage: deploy
when : manual
script:
- xcopy /y c:\TMP\*.* $DEPLOY_FOLDER\
Now I need to deploy a Windows Service(WinService.csproj in my solution) on a remote machine, How can I do it in my yml file?
Related
I am trying to build CI/CD for a nodejs application using Azure pipeline to be deployed in Azure VM . I can see the build being successful but the deployment is not .
Can anyone help me with bash command to start the node server.
The below is the yaml portion of deploy stage
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: VMDeploy
displayName: web
environment:
name: VMtest
resourceType: VirtualMachine
tags: web
strategy:
runOnce:
deploy:
steps:
- script: echo my first deployment
I am new and is trying set up a CICD pipeline. The CI build stage is not uploading artifacts as shown. I have provide the current yml script below. what are the steps to correct errors in order to generate an artifacts for deployment.
Gitlab yaml script:
stages:
- build
- deploy
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_REGION: $AWS_REGION
S3_BUCKET_NAME: $S3_BUCKET_NAME
build:
tags: [docker]
stage: build
image: node:latest
script:
- cd client
- npm install
- CI='' npm run build-prod
artifacts:
expose_as: 'Arti-Reports'
paths:
- build.
expire_in: 24 hour
when: on_success
the build job in CI pipeline shown as:
Uploading artifacts for successful job
Uploading artifacts...
WARNING: build.: no matching files
ERROR: No files to upload
Cleaning up file based variables
For my ASP .Net Core project, I am trying to integrate CI/CD with Azure.
There, I tried to create an Azure pipeline with GitHub as follows:
Since I have already created .yml file in my GitHub Repository I decided to go with the option Existing Azure Pipeline YAML file option.
I have already created the following yml file in the Github repo in the path .github/workflows/dotnet.yml
Here is the dotnet.yml file:
name: .NET
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET
uses: actions/setup-dotnet#v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
# - name: Test
# run: dotnet test --no-build --verbosity normal
But I am getting the two errors as:
/.github/workflows/dotnet.yml(Line: 3, Col: 1): Unexpected value 'on'
/.github/workflows/dotnet.yml(Line: 10, Col: 1): A mapping was not
expected
I do not understand why I am getting these errors. When I push to the repository the .NET builds run and it builds successfully.
Can somebody please let me know how to solve these two errors and what the fault in my YAML file is?
It looks like you try to run github actions build this is why its not working have a look into documentation how to structure your build
In Azure pipeline it will smth like this
steps:
- task: UseDotNet#2
inputs:
packageType: 'sdk'
version: '5.0.x'
- task: DotNetCoreCLI#2
displayName: Restore
inputs:
command: restore
projects: '**/*.csproj'
- script: dotnet build --no-restore
displayName: 'Build'
workingDirectory: SET_WORK_DIR
Hi in my case I use Gitlab community and Sonar Qube. The Sonar is hosted on Azure Ubuntu VM with a Docker container. Before my Sonar was on a Windows machine and here is the part of gitlab.yml.
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
stages:
- build
- test
before_script:
- Set-Variable -Name "time" -Value (Get-Date -Format "%H:%m")
- echo ${time}
- echo "started by ${GITLAB_USER_NAME}"
build:
stage: build
only:
- branches
script:
- echo "running scripts in the build job"
- choco feature enable -n=allowGlobalConfirmation
- choco install netfx-4.6.2-devpack
- choco install dotnetcore-sdk
- nuget restore -ConfigFile .\nuget.config
- msbuild ".\MyProject\MyProject.csproj" /p:DeployOnBuild=true /p:PublishProfile="Local Publish" /p:WarningLevel=0
- dotnet build ".\MyProject.Tests\MyProject.Tests.csproj" --configuration Release
artifacts:
paths:
- Publish
- .\MyProject.Tests\bin\Release\netcoreapp3.1\**
- .\MyProject
expire_in: 1 day
after_script:
- Remove-Item -Recurse -Force .\packages\
sonarcloud-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
dependencies:
- build
script:
- choco install sonarqube-scanner.portable
- SonarScanner.MSBuild.exe begin /k:"myProject" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"
- nuget restore -ConfigFile .\nuget.config
- MsBuild.exe ./MyProject /t:Rebuild
- SonarScanner.MSBuild.exe end /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"
only:
- merge_requests
- master
- develop
- GitLabQualityTool
I know that this yml is not the best but it's work. The main project is on .net 4.6.2.Sonar is running on Ubuntu on port 80:9000. The point is that I am started to use Azure, Docker, and Sonar before a week. Can somebody help me with yml configuration?
I am trying to setup ci with gitlab-ci. And I have a few questions about it.
It looks like there is no rollback mechanism on gitlab-ci. So should i care about rolling back if deploy stage fails?
I'am planning to use "dotnet publish Solution.sln -c release" script. But I have multiple projects in this solution. It has one classlib and 2 api. (like AdminApi and UserApi). And these 2 apis are hosted different sites in IIS. In this case, how can i configure dotnet publish script with params?
Should i use something like xcopy for moving publish output to iis folder?
I've put an app_offile.htm_for each web sites in iis with "We'll back soon message" in html.
And I've solved my problem with this gitlab-ci.yml
stages:
- build
- test
- deploy
build:
stage: build
script:
- echo "Building the app"
- "dotnet publish MySolution.sln -c release"
artifacts:
untracked: true
only:
- dev
test:
stage: test
script: echo "Running tests"
artifacts:
untracked: true
dependencies:
- build
only:
- dev
deploy_staging:
stage: deploy
script:
- echo "Deployintg to staging server Admin"
- ren c:\\inetpub\\vhosts\\xxx\\admin\\app_offline.htm_ app_offline.htm
- dotnet publish PathToAdmin.csproj -c release -o c:\\inetpub\\vhosts\\xxx\\admin
- ren c:\\inetpub\\vhosts\\xxx\\admin\\app_offline.htm app_offline.htm_
- echo "Deployintg to staging server User"
- ren c:\\inetpub\\vhosts\\xxx\\user\\app_offline.htm_ app_offline.htm
- dotnet publish PathToUser.csproj -c release -o c:\\inetpub\\vhosts\\xxx\\user
- ren c:\\inetpub\\vhosts\\xxx\\user\\app_offline.htm app_offline.htm_
dependencies:
- build
only:
- dev