Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CICD in WindowServer #4

Closed
SAgiKPJH opened this issue Mar 11, 2024 · 3 comments
Closed

CICD in WindowServer #4

SAgiKPJH opened this issue Mar 11, 2024 · 3 comments
Assignees

Comments

@SAgiKPJH
Copy link
Contributor

  • CICD를 Windowserver에서 구성합니다.
@SAgiKPJH
Copy link
Contributor Author

SAgiKPJH commented Mar 12, 2024

GitLab CI/CD 환경 구축



GitLab Runner 활용

1. 원하는 window 환경을 준비합니다.


2. GitLab Runner 설치 합니다.

image

  • 이름을 gitlab-runner.exe로 변경하고 폴더 위치를 C:\GitLab-Runner에 지정합니다.
  • 또한 해당 폴더와 exe파일에 쓰기권한 할당합니다. (보통 되어 있습니다.)

3. GitLab Register

  • https://docs.gitlab.com/runner/register/index.html?tab=Windows
  • Window의 경우 다음과 같이 Register 시도합니다.
    C:\GitLab-Runner\gitlab-runner.exe register\
    --non-interactive \
    --url "https://gitlab.com/" \
    --registration-token "$RUNNER_TOKEN" \
    --executor "shell" \
    --shell "pwsh"  \
    --tag-list "sampletags, windows" \
    --description "windowlocalrunner"
  • 내용 기입 방법은 다음을 따릅니다.
    image
    image
  • URL은 해당 내용에서 제공하는 URL을 사용합니다.
  • token은 해당 내용에서 제공하는 registration token을 입력합니다.
    • 이때, Shared runners는 비활성화합니다. (가만히 냅둡니다)
  • description는 Runner 이름을 입력합니다. (예 - TestRunner)
  • 등록 완료되면 다음과 같이 등록이 됩니다.
    image
    image
  • 생성된 파일 config.toml은 다음과 같이 나타납니다.
concurrent = 1
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Test"
  url = "~~~(URL)~~~"
  id = 241
  token = "~~~~~~~~~~~~"
  token_obtained_at = 2024-03-13T01:48:17Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  shell = "powershell"
  [runners.cache]
    MaxUploadedArchiveSize = 0

4. GitLab Start

  • 동작 이전 상태
    image
  • gitlab-runner 상태 확인
> .\gitlab-runner.exe status
Runtime platform                                    arch=amd64 os=windows pid=11836 revision=782c6ecb version=16.9.1
gitlab-runner: the service is not installed
  • gitlab-runner 관리자 권한으로 install
> ./gitlab-runner.exe install
Runtime platform                                    arch=amd64 os=windows pid=19044 revision=782c6ecb version=16.9.1
  • gitlab-runner Install 후 상태 확인
> ./gitlab-runner.exe status
Runtime platform                                    arch=amd64 os=windows pid=13224 revision=782c6ecb version=16.9.1
gitlab-runner: Service has stopped
  • gitlab-runner 정보 확인
> .\gitlab-runner.exe list
Runtime platform                                    arch=amd64 os=windows pid=9616 revision=782c6ecb version=16.9.1
Created missing unique system ID                    system_id=s_6429108e4109
Listing configured runners                          ConfigFile=C:\GitLab-Runner\config.toml
  • gitlab-runner 시작
> ./gitlab-runner.exe start gitlab-runner
Runtime platform                                    arch=amd64 os=windows pid=26136 revision=782c6ecb version=16.9.1
  • gitlab-runner 시작 후 상태 확인
> ./gitlab-runner.exe status
Runtime platform                                    arch=amd64 os=windows pid=28320 revision=782c6ecb version=16.9.1
gitlab-runner: Service is running

image

  • 동작 이후 상태
    image
  • 만일 초록색 원이 나타나지 않으면, 다시한번 Runner를 Regist합니다.

@SAgiKPJH
Copy link
Contributor Author

SAgiKPJH commented Mar 12, 2024

빌드 테스트 (Test 코드 포함)

  • GitLab .gitlab-ci.yml파일 설정합니다.
  • GitLab > Settings > CI/CD의 General
    image
  • 레파지토리에 바로 구성해도 좋습니다.
  • ID나 Password 등 보안에 민감한 변수는 GitLab의 Settings > CI/CD 의 Variables에서 세팅해서 사용합니다.
    image
  • 해당하는 브랜치에 .gitlab-ci.yml 작성합니다.
stages:
  - build

build:
  stage: build
  tags:
    - adc60
  variables:
    SOLUTION_PATH: ./Src/ADC/Mirero.ADC.App.sln
    TEST_PROJECT_PATH: ./Src/ADC/Tests/Client.Business.UnitTest/Client.Business.UnitTest.csproj
  script:
    - dotnet restore $SOLUTION_PATH
    - dotnet build $SOLUTION_PATH --configuration Release

test:
  stage: build
  image: mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019
  variables:
    TEST_PROJECT_PATH: ./Src/ADC/Tests/Client.Business.UnitTest/Client.Business.UnitTest.csproj
  script:
    - dotnet test $TEST_PROJECT_PATH --configuration Release
  • 이후 Commit하여 Build가 되는지 확인합니다.
    image
    image
    image

@SAgiKPJH
Copy link
Contributor Author

SAgiKPJH commented Apr 30, 2024

dotnet sdk version 지정

dotnet new globaljson --sdk-version 7.0.000 --force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant