일반 Docker 컨테이너 이미지를 사용하여 파이프라인에 대한 사용자 지정 작업 구현

  • 릴리스 버전: Yokohama
  • 업데이트 날짜 2025년 01월 30일
  • 읽기47분
  • ServiceNow 사용자 지정 작업을 사용하여 일반 Docker 컨테이너 이미지의 도움을 받아 파이프라인에서 변경 요청 생성, Sonar 스캔, 아티팩트 등록 및 패키지 등록과 관련된 데이터를 수집합니다.

    Docker 이미지는 애플리케이션을 실행하는 데 사용할 수 있는 소프트웨어 패키지입니다. 이 이미지는 컨테이너를 인스턴스화하는 방법과 실행해야 하는 소프트웨어 구성 요소를 알려줍니다. Docker 컨테이너는 애플리케이션 코드와 애플리케이션을 실행하는 데 필요한 모든 종속성을 결합한 가상 환경입니다. Docker에 대한 자세한 내용은 Docker 설명서를 참조하십시오.

    에 대한 환경 변수 GitLab

    이미지를 구성하려면 Docker 프로젝트의 인스턴스에서 다음 환경 변수를 사용할 수 GitLab 있어야 합니다.
    • SNOW_TOKEN: 토큰 번호입니다 ServiceNow . 마스킹된 변수이며 작업에 표시되지 않습니다.
    • SNOW_TOOLID: ServiceNow 도구 ID입니다.
    • SNOW_URL: ServiceNow 인스턴스 URL.
    프로젝트를 구성 GitLab 하면 프로젝트에 대한 환경 변수가 만들어지고 최근에 구성된 변수 값이 고려됩니다. 업그레이드 고객인 경우 기존 GitLab 프로젝트를 다시 구성하거나 인스턴스에 환경 변수를 수동으로 추가해야 합니다 GitLab . 변수 추가에 대한 자세한 내용은 GitLab 설명서를 참조하십시오.

    SNOW_TOKEN 변수를 추가할 때 도구 [sn_devops_tool] 테이블에 있는 도구 기록에서 토큰 복사 버튼을 선택하여 토큰을 가져올 수 있습니다.

    환경 변수는 도구 기록 페이지의 수동으로 웹후크 구성 팝업에서 사용할 수 있는 값으로 업데이트해야 합니다. 연결 세부 정보를 보는 방법에 대한 자세한 내용은 문서를 에서 GitLab 수동으로 웹후크 구성참조하십시오도구 기록에서 웹후크 구성.

    GitLab에 대한 연결 상세 정보

    에 대한 환경 변수 GitHub Actions

    이미지를 구성하려면 Docker 인스턴스에서 특정 환경 변수를 사용할 수 GitHub Actions 있어야 합니다.

    GitHub Actions 인스턴스에서 다음 환경 변수를 구성해야 합니다.
    주:
    도구 기록 페이지의 웹후크 수동 구성 팝업에서 사용할 수 있는 값으로 변수를 업데이트해야 합니다.
    • SNOW_TOKEN: 토큰 번호입니다 ServiceNow . 마스킹된 변수이며 작업에 표시되지 않습니다.
    • SNOW_TOOLID: ServiceNow 도구 ID입니다.
    • SNOW_URL: ServiceNow 인스턴스 URL.
    주:
    에서 GitHub Actions변수 추가에 대한 자세한 내용은 GitHub 설명서를 참조하십시오.
    GitHub Actions 파이프라인에 다음 환경 변수를 전달해야 합니다.
    주:
    이러한 변수의 값은 GitHub에서 동적으로 검색되며 별도로 구성할 필요가 없습니다.
    • CI_PIPELINE_ID: 리포지토리의 워크플로우 실행 ID입니다. 사용량 - CI_PIPELINE_ID: ${{github.run_id }}
    • CI_API_V4_URL: GitHub 서버의 URL. 사용량 - CI_API_V4_URL: ${{ github.server_url }}
    • CI_JOB_ID: 리포지토리의 워크플로우 실행 ID입니다. 사용량 - CI_PIPELINE_ID: ${{github.run_id }}
    • CI_PROJECT_PATH: 워크플로우의 이름입니다. 사용법 - CI_PROJECT_PATH: ${{ github.repository }}/${{github.workflow}}
    • CI_REPOSITORY_NAME: 리포지토리의 이름입니다. 사용량 - CI_REPOSITORY_NAME: ${{ github.repository }}
    • CI_RUN_ATTEMPT: 워크플로우 시도 횟수입니다. 사용량 - CI_RUN_ATTEMPT: ${{ github.run_attempt }}
    • CI_PROJECT_TITLE: 워크플로우의 이름입니다. 사용량 - CI_PROJECT_TITLE: ${{ github.repository }}/${{github.workflow}}
    • CI_COMMIT_BRANCH: 워크플로우가 실행되는 분기의 이름입니다. 사용량 - CI_COMMIT_BRANCH: ${{ github.ref_name }}
    • CI_WORKFLOW_NAME: 워크플로우의 이름입니다. 사용량 - CI_WORKFLOW_NAME: ${{ github.workflow }}
    리포지토리를 구성하면 리포지토리에 대한 환경 변수가 만들어지고 최근에 구성된 변수 값이 고려됩니다. 업그레이드하는 고객인 경우 기존 리포지토리를 다시 구성하거나 인스턴스에 환경 변수를 수동으로 추가해야 합니다.

    GitHub 작업에 대한 연결 상세 정보

    하네스에 대한 환경 변수

    이미지를 구성하려면 Docker 하네스 인스턴스에서 특정 환경 변수를 사용할 수 있어야 합니다.

    Harness 인스턴스에서 다음 환경 변수를 구성해야 합니다.
    주:
    도구 기록 페이지의 웹후크 수동 구성 팝업에서 사용할 수 있는 값으로 변수를 업데이트해야 합니다.
    • SNOW_TOKEN: 토큰 번호입니다 ServiceNow . 마스킹된 변수이며 작업에 표시되지 않습니다.
    • SNOW_TOOLID: ServiceNow 도구 ID입니다.
    • SNOW_URL: ServiceNow 인스턴스 URL.

    Harness 파이프라인에 다음 환경 변수를 전달해야 합니다.

    • HARNESS_STAGE_NAME: "<+stage.identifier>"

    • HARNESS_PIPELINE_NAME: "<+org.identifier>/<+project.identifier>/<+pipeline.name>"

    리포지토리를 구성하면 리포지토리에 대한 환경 변수가 만들어지고 최근에 구성된 변수 값이 고려됩니다. 업그레이드하는 고객인 경우 기존 리포지토리를 다시 구성하거나 인스턴스에 환경 변수를 수동으로 추가해야 합니다.

    수동으로 웹후크 화면 구성

    ServiceNow Docker 이미지

    파이프라인에 사용자 지정 작업을 추가하기 전에 파이프라인에서 ServiceNow Docker 이미지(servicenowdocker/sndevops:5.1.0)를 전달해야 합니다. 에 있는 app-devops-gitlab 공용 리포지토리를 복제하고 다음 명령을 실행하여 Docker 이미지를 생성할 수 있습니다.https://github.com/ServiceNow/app-devops-gitlab
    docker build -t servicenowdocker/sndevops:5.1.0
    docker push servicenowdocker/sndevops:5.1.0
    .yml 파일의 시작 부분에 Docker 이미지를 추가할 수 있습니다. 각 작업에 별도로 추가할 필요가 없습니다.
    주:
    여러 이미지를 사용하려면 작업 수준에서 추가합니다.

    app-devops-gitlab 퍼블릭 리포지토리를 사용자 지정하고 파이프라인에 전달할 고유한 Docker 이미지를 만들 수도 있습니다.

    ServiceNow DevOps 변경 단계

    ServiceNow 직무 수준에서 DevOps 변경 사용자 지정 단계를 추가하여 ServiceNow 인스턴스에서 변경을 생성합니다. 예:
    
    stages:
      - DevOpsChangeApproval
    
    ServiceNow DevOps Change:
      stage: DevOpsChangeApproval
      image: servicenowdocker/sndevops:5.1.0
      script: 
        - sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"attributes\":{\"short_description\":\"Software Deployment\",\"description\":\"Software Deployment.\",\"assignment_group\":\"xxxxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
    
    
    주:
    Docker 변경 단계와 시기: 수동 지침 변경 단계를 모두 사용하는 경우 서로 다른 작업 수준에서 추가해야 합니다.

    이 사용자 지정 작업에 대한 입력 값을 JSON 형식 문자열로 입력해야 합니다.

    • changeStepDetails: [선택 사항] 시간 제한 및 간격 세부 정보를 보유합니다.
    • interval: [선택 사항] API를 시도하는 사이에 대기하는 시간(초)입니다. 기본값은 100초입니다.
    • timeout: [선택 사항] 작업이 실패할 때까지 대기하는 최대 시간(초)입니다. 기본값은 3600초입니다.
      주:
      여기뿐만 아니라 도구에서도 시간 제한 값을 사용할 수 있는 경우 이전 시간 제한 값이 고려됩니다.
    • attributes: [선택 사항] 변경 요청 속성 상세 정보는 인스턴스에서 변경을 ServiceNow 생성하는 동안 사용됩니다. 변경 요청은 쉼표(,)로 구분된 키-값 쌍을 포함하는 중괄호 {}로 둘러싸인 JSON 객체입니다. 키-값 쌍은 콜론(:))으로 구분된 키와 값으로 구성됩니다. 키-값 쌍에서 지원되는 키는 short_description, 설명, assignment_group, implementation_plan, backout_plan, test_plan 등입니다.
    • -ctx: [선택 사항] JSON 형식의 추가 컨텍스트 매개변수입니다. DevOps 변경 API에 대한 요청을 빌드하는 데 사용될 GitHub의 환경 변수 상세 정보입니다. 예:
      sndevopscli create change -ctx "{\"projectId\": \"123456\", \"attemptNumber\": \"${{ github.run_attempt }}\"}" -p "{\"changeStepDetails\": {\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"G Venkata Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"a715cd759f2002002920bde8132e7018\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
    • -w: [선택 사항] 파이프라인이 변경 생성 및 승인을 기다려야 하는지 여부를 지정합니다. 기본적으로 파이프라인은 변경 생성 및 승인이 완료될 때까지 대기합니다.
    주:
    변경 단계의 이름에는 작업 이름인 ServiceNow DevOps 변경 키워드가 포함되어야 합니다.

    ServiceNow DevOps SonarScan 결과

    ServiceNow 직무 수준에서 DevOps SonarScan 결과 사용자 지정 단계를 추가하여 ServiceNow 인스턴스에 Sonar 요약을 생성합니다. 예:
    
    stages:
      - DevOpsSonarStage
    
    ServiceNow DevOps SonarScan Results:
      stage: DevOpsSonarStage
      image: servicenowdocker/sndevops:5.1.0
      script: 
        - sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'devsystem2019_TestImportTest'
    
    
    • url: [필수] 소나 URL을 지정합니다.
    • projectKey: [필수] Sonar 프로젝트 키를 지정합니다.
    주:
    소나 단계의 이름은 ServiceNow DevOps SonarScan 결과인 작업 이름과 같아야 합니다.
    제한사항
    소프트웨어 품질 요약 결과를 생성하는 동안 CI_MERGE_REQUEST_SOURCE_BRANCH_NAME 환경 변수는 병합 파이프라인에 사용되며, CI_COMMIT_BRANCH 변수는 병합 또는 태그 파이프라인에 사용할 수 없기 때문에 CI_DEFAULT_BRANCH 태그 파이프라인에 사용됩니다. 자세한 내용은 GitLab 설명서를 참조하십시오.

    아티팩트 등록

    직무 수준에서 아티팩트 사용자 지정 단계를 추가하여 ServiceNow 인스턴스에 아티팩트를 등록합니다. 예:
    
    stages:
      - artifact
    
    artifact:
      stage: artifact
      image: servicenowdocker/sndevops:5.1.0
      script: 
        - sndevopscli create artifact -a "[{\"name\":\"Artifact-${CI_JOB_NAME}\",\"repositoryName\":\"Repo\",\"version\":\"1.${CI_JOB_ID}.0\"}]"
     

    이 사용자 지정 작업에 대한 입력 값을 JSON 형식 문자열로 입력해야 합니다.

    -a: [필수] 아티팩트 상세 정보를 지정합니다.

    패키지 등록

    작업 수준에서 패키지 사용자 지정 단계를 추가하여 ServiceNow 인스턴스에 패키지를 등록합니다. 예:
    
    stages:
      - package
    
    package:
      stage: package
      image: servicenowdocker/sndevops:5.1.0
      script: 
        - sndevopscli create package -n "Package2" -a "[{\"name\":\"Artifact-${CI_JOB_NAME}\",\"repositoryName\":\"Repo\" ,\"version\":\"1.${CI_JOB_ID}.0\"}]"

    이 사용자 지정 작업에 대한 입력 값을 JSON 형식 문자열로 입력해야 합니다.

    -n: [필수] 패키지 이름을 지정합니다.

    변경 사항 가져오기

    작업 수준에서 추가하여 변경 요청을 식별하기 위해 지정된 changeDetails가 ServiceNow 있는 인스턴스에서 changeRequestNumber를 가져옵니다.

    예:
    
    
    stages:
      - DevOpsGetChange
    
    ServiceNow DevOps Get Change:
      stage: DevOpsGetChange
      image: servicenowdocker/sndevops:5.1.0
      script: 
        - sndevopscli get change -p "{\"buildNumber\":${CHG_JOB_ID},\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"GitlabDockerGetAndUpdateChange\"}"
    
    -p: It stands for changeDetails. The change details to be used for identifying change request in ServiceNow instance. The change details is a JSON object surrounded by curly braces {} containing key-value pair separated by a comma ,. A key-value pair consists of a key and a value separated by a colon :. The keys supported in key-value pair are buildNumber, pipelineName, stageName
    
    buildNumber: [mandatory]
    This specifies ID of the Job where we have created change request.
    
    stageName: [mandatory]
    This specifies the Job name where we have created change request..
    
    pipelineName: [mandatory]
    This specifies the pipeline name.
    
    Outputs:
      sndevopschg.json file created with content: {
        "status": "SUCCESS",
        "changeRequestNumber": "CHGXXXXX"
      }
      
      changeRequestNumber: Change Request Number found for the given change details
      status: To know the status of the Change Request GET.
    

    변경 업데이트

    작업 수준에서 추가하여 changeRequestDetails와 함께 입력으로 제공된 changeRequestNumber에 대한 인스턴스의 변경을 ServiceNow 업데이트합니다.

    예:
    
    stages:
      - DevOpsUpdateChangeStage
    
    ServiceNow DevOps Update Change:
      stage: DevOpsUpdateChangeStage
      image: servicenowdocker/sndevops:5.1.0
      script: 
        - sndevopscli update change -n 'CHGXXXXXX' -p "{\"short_description\":\"G Venkata12345 Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXX\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
    
    -n [Not mandatory if we have sndevopschg.json in our pipeline yml]: It stands for changeRequestNumber. The change request number to identify a unique change request. 
       Precedence of choosing changeRequestNumber: 
         - changeRequestNumber mentioned in the pipeline yml
         - changeRequestNumber stored in sndevopschg.json.
    
    -p : It stands for changeDetails. The change details to be used for Updating the change request information identified by the specified change request number with the key-value pairs. The change details is a JSON object surrounded by curly braces {} containing key-value pair separated by a comma ,. A key-value pair consists of a key and a value separated by a colon :. The keys supported in key-value pair are short_description, state, description, work_notes ..so on
    
    OR
      - sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXXXXXXX\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
    
    NOTE: State should be specified at last in case if you are update the state of change request.
    - sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXXXXXXX\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\","state":"3"}'
    

    변경 자동 종결

    인스턴스에 자동 종결 변경을 ServiceNow 통합합니다. 자동 종결에 대한 자세한 내용은 다음 문서를 참조하십시오 파이프라인 내에서 변경 요청 상세 정보 구성 DevOps.

    예:
    
    stages:
      - changeapproval
    
    ServiceNow DevOps Change Step:
      stage: changeapproval
      image: servicenowdocker/sndevops:5.1.0
      script: 
         - sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"G Venkata Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
      
    autoCloseChange: [optional] : Boolean value
    

    보안 스캔 결과

    보안 검사 결과를 검색하려면 ServiceNow 직무 수준에서 DevOps 보안 검사 결과 사용자 지정 단계를 추가합니다. 예:
    stages:
      - DevOpsSecurityScanStageServiceNow 
    
    ServiceNow DevOps Security Scan Results:
      stage: DevOpsSecurityScanStageimage 
      image: servicenowdocker/sndevops:5.1.0
      script: 
          - sndevopscli create securityScan -p "{\"pipelineInfo\":{\"buildNumber\":\"${CI_PIPELINE_ID}\",\"pipelineExecutionUrl\":\"${CI_PIPELINE_URL}\" },\"securityResultAttributes\":{ \"scanner\":\"Veracode\",\"applicationName\":\"PetStoreAPI-Github\",\"buildVersion\":\"\",\"securityToolId\":\"\"}}"
      -p: [mandatory]It the payload of security result attributes. The payload will have attributes as follows:
        buildNumber: CI_PIPELINE_ID (mandatory)pipelineExecutionUrl: CI_PIPELINE_URL (mandatory)scanner: Scanning tool and is required e.g. Checkmarx One.projectName/projectId: Name/Id of your Checkmarx One project and is required. This attribute is applicable only for Checkmarx One.applicationName: Name of your Veracode application and is required. This attribute is applicable only for Veracode.buildVersion": Veracode Scan name / build version and is optional. This attribute is applicable only for Veracode.scanId: Checkmarx One scan id and is optional. This attribute is applicable only for Checkmarx One.securityToolId: Security tool onboarded in ServiceNow (sys_id of the onboarded security tool) and is optional.
     

    샘플 파이프라인

    샘플 GitLab 파이프라인

    
    image: servicenowdocker/sndevops:5.1.0
    stages:
      - pre-build
      - build
      - sonar
      - securityscan
      - changeapproval
      - getchange
      - updatechange
      - deploy
    
    
    Pre-Build:
      stage: pre-build
      script:
        - echo $CI_JOB_NAME
        
    Artifact and Package:
      stage: build
      script:
        - sndevopscli create artifact -a "[{\"name\":\"Artifact-${CI_JOB_NAME}\",\"repositoryName\":\"TestRepo\",\"version\":\"1.${CI_RUNNER_ID}.0\"}]"
        - sndevopscli create package -n "Test_Package" -a "[{\"name\":\"Artifact-${CI_JOB_NAME}\",\"repositoryName\":\"TestRepo\",\"version\":\"1.${CI_RUNNER_ID}.0\"}]"
    
    
    ServiceNow DevOps SonarScan Results:
      stage: sonar
      script:
        - sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'xxxxxxx'
    
    
    ServiceNow DevOps Security Scan Results:
      stage: securityscan
      script:
        - sndevopscli create securityScan -p "{\"pipelineInfo\":{\"buildNumber\":\"${CI_JOB_ID}\", \"stageName\":\"ServiceNow DevOps Security Scan Results\",\"taskExecutionUrl\":\"${CI_JOB_URL}\" },\"securityResultAttributes\":{ \"scanner\":\"Veracode\",\"applicationName\":\"PetStoreAPI-Github\",\"buildVersion\":\"\",\"securityToolId\":\"\"}}"
    
    ServiceNow DevOps Change Step:
      stage: changeapproval
      variables:
        CHG_JOB_ID: $CI_JOB_ID
      script: 
         - echo "CHG_JOB_ID=$CHG_JOB_ID" >> generated_job_id.env
         - sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"G Venkata Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"a715cd759f2002002920bde8132e7018\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
         - sndevopscli get change #If we are placing get change cli command in the same job where we are creating change then no need to mention the changeDetails.
      artifacts:
        paths:
          - generated_job_id.env
    
    DevOps Get Change:
      stage: getchange
      script:
        - source generated_job_id.env
        - sndevopscli get change -p "{\"buildNumber\":${CHG_JOB_ID},\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"SmrutiTestDemoProject\"}"
      artifacts:
        paths:
          - sndevopschg.json  
      dependencies:
        - ServiceNow DevOps Change Step
    
    DevOps Update Change:
      stage: updatechange
      script:
        #- sndevopscli update change -n 'CHGXXXX' -p "{\"short_description\":\"Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
        - sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
      dependencies:
        - DevOps Get Change
    
    Deploy Job:
      stage: deploy
      script:
        - echo $CI_JOB_NAME

    샘플 GitHub Actions 파이프라인

    name: GithubAction
    
    on:
      push:
        branches: ["main"]
      pull_request:
        branches: ["main"]
    
    permissions:
      contents: read
    env:
      SNOW_URL: ${{ secrets.SNOW_URL }}
      SNOW_TOKEN: ${{ secrets.SNOW_TOKEN }}
      SNOW_TOOLID: ${{ secrets.SNOW_TOOLID }}
      # These are the optional env variables
      #CI_PIPELINE_ID: ${{ github.run_id }}
      #CI_API_V4_URL: ${{ github.server_url }}
      #CI_JOB_ID: ${{ github.run_id }}
      #CI_PROJECT_PATH: ${{ github.job }}
      #CI_REPOSITORY_NAME: ${{ github.repository }}
      #CI_RUN_ATTEMPT: ${{ github.run_attempt }}
      #CI_PROJECT_TITLE: ${{ github.repository }}/${{github.workflow}}
      #CI_COMMIT_BRANCH: ${{ github.ref_name }}
      #CI_WORKFLOW_NAME: ${{ github.workflow }}
    
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - name: Set up JDK 17
            run: |
              echo 'hello'
    
      ServiceNowDevOpsChange:
         runs-on: ubuntu-latest
         needs: build
         container:
           image: servicenowdocker/sndevops:5.1.0
         env:
           CI_JOB_NAME: "ServiceNowDevOpsChange"
    
         steps:
           - name: create change
             run: |
               sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":10},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"G Venkata Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"a715cd759f2002002920bde8132e7018\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
    
      ServiceNowUpdateDevOpsChange:
           runs-on: ubuntu-latest
           needs: ServiceNowDevOpsChange
           container:
             image: servicenowdocker/sndevops:5.1.0
           env:
             CI_JOB_NAME: "ServiceNowDevOpsChange"
      
           steps:
             - name: update change
               run: |
                 sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"a715cd759f2002002920bde8132e7018\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
    
      ArtifactAndPackage:
          runs-on: ubuntu-latest
          needs: build
          container:
            image: servicenowdocker/sndevops:5.1.0
          env:
            CI_JOB_NAME: "ArtifactAndPackage"
          steps:
            - name: create artifact
              run: |
                 sndevopscli create artifact -a "[{\"name\": \"com:customactiondemo\",\"version\": \"1.${{ github.run_number }}\",\"semanticVersion\": \"1.${{ github.run_number }}.0\",\"repositoryName\": \"${{ github.repository }}\"}]"
                 sndevopscli create package -n "Test_Package" -a "[{\"name\": \"com:customactiondemo\",\"version\": \"1.${{ github.run_number }}\",\"semanticVersion\": \"1.${{ github.run_number }}.0\",\"repositoryName\": \"${{ github.repository }}\"}]"
    
      ServiceNowDevOpsSonarScanResults:
          name: ServiceNowDevOpsSonarScanResults
          needs: ArtifactAndPackage
          runs-on: ubuntu-latest
          container:
            image: servicenowdocker/sndevops:5.1.0
          env:
            CI_JOB_NAME: "ServiceNowDevOpsSonarScanResults"
          steps:
            - name: devops soanr results
              run: |
                sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'xxxxxxx'
    
      ServiceNowDevOpsSecurityScan:
          name: ServiceNowDevOpsSecurityScan
          runs-on: ubuntu-latest
          needs: build
          container:
            image: servicenowdocker/sndevops:5.1.0
          steps:
            - name: security scan
              run: |
               sndevopscli create securityScan -p "{ \"pipelineInfo\": {  \"runId\": \"${{ github.run_id }}\",   \"runNumber\": \"${{ github.run_number }}\", \"runAttempt\": \"${{ github.run_attempt }}\",   \"job\": \"ServiceNowDevOpsSecurityScan\",  \"workflow\": \"${{ github.workflow }}\",  \"repository\": \"${{github.repository}}\" }, \"securityResultAttributes\": { \"scanner\": \"Veracode\",    \"applicationName\": \"PetStoreAPI-Github\",\"buildVersion\": \"\",   \"securityToolId\": \"\"}}"
    

    샘플 하네스 파이프라인

    # This is an example pipeline, and your pipeline and container configurations may vary from the setup shown here.
    # Refer to the pipeline stages for Security, Software, and Change configurations. 
    # Using this YAML file directly will not work as it contains several Harness-specific configurations; check the Command section present for container steps.
    pipeline:
      name: Example pipeline
      identifier: Example_pipeline 
      projectIdentifier: Example_project
      orgIdentifier: ExampleOrg
      tags: {}
      stages:
        - stage:
            name: Build
            identifier: Build
            description: ""
            type: Custom
            spec:
              execution:
                steps:
                  - step:
                      type: ShellScript
                      name: ShellScript_1
                      identifier: ShellScript_1
                      spec:
                        shell: Bash
                        executionTarget: {}
                        source:
                          type: Inline
                          spec:
                            script: echo "Building.."
                        environmentVariables: []
                        outputVariables: []
                      timeout: 10m
            tags: {}
        - stage:
            name: ServiceNow DevOps Sonar Scan Results
            identifier: ServiceNow_DevOps_Sonar_Scan_Results
            description: ""
            type: Custom
            spec:
              execution:
                steps:
                  - step:
                      type: Container
                      name: Sonar container
                      identifier: Sonar_container
                      spec:
                        connectorRef: docker_connector # harness docker connector
                        image: servicenowdocker/sndevops:5.1.0
                        command: |-
                          export SNOW_URL="<+variable.SNOW_URL>"
                          export SNOW_TOOLID="<+variable.SNOW_TOOLID>"
                          export SNOW_TOKEN="<+variable.SNOW_TOKEN>"
                          export HARNESS_STAGE_NAME="<+stage.identifier>"
                          export HARNESS_PIPELINE_NAME="<+org.identifier>/<+project.identifier>/<+pipeline.name>"
                          export CI_COMMIT_BRANCH="main"
                          sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'SONAR_PROJECT_KEY' -branch "main"
                        shell: Sh
                        infrastructure:
                          type: KubernetesDirect
                          spec:
                            connectorRef: KUBE_CONNECTOR # harness kubernates connector
                            namespace: harness-delegate-ng
                            resources:
                              limits:
                                cpu: "0.5"
                                memory: 500Mi
                            annotations: {}
                            labels: {}
                            containerSecurityContext:
                              capabilities:
                                drop: []
                                add: []
                            nodeSelector: {}
                        reports:
                          type: JUnit
                          spec:
                            paths: []
                        outputVariables: []
                        envVariables: {}
                      timeout: 1h
            tags: {}
        - stage:
            name: ServiceNow DevOps Security Scan Results
            identifier: ServiceNow_DevOps_Security_Scan_Results
            description: ""
            type: Custom
            spec:
              execution:
                steps:
                  - step:
                      type: Container
                      name: security
                      identifier: security
                      spec:
                        connectorRef: docker_connector # harness docker connector
                        image: servicenowdocker/sndevops:5.1.0
                        command: |-
                          export SNOW_URL="<+variable.SNOW_URL>"
                          export SNOW_TOOLID="<+variable.SNOW_TOOLID>"
                          export SNOW_TOKEN="<+variable.SNOW_TOKEN>"
                          sndevopscli create securityScan -p \
                          "{\"pipelineInfo\":{
                              \"buildNumber\":\"<+stage.nodeExecutionId>\",
                              \"taskExecutionUrl\":\"<+pipeline.executionUrl>?stage=<+stage.nodeExecutionId>\", 
                              \"orchestrationPipeline\":\"<+org.identifier>/<+project.identifier>/<+pipeline.name>\" 
                            },
                            \"securityResultAttributes\":{
                               \"scanner\":\"Veracode\",
                               \"applicationName\":\"VeraDemo-10\"
                            }
                          }"
                        shell: Sh
                        infrastructure:
                          type: KubernetesDirect
                          spec:
                            connectorRef: KUBE_CONNECTOR # harness kubernates connector
                            namespace: harness-delegate-ng
                            resources:
                              limits:
                                cpu: "0.5"
                                memory: 500Mi
                            annotations: {}
                            labels: {}
                            containerSecurityContext:
                              capabilities:
                                drop: []
                                add: []
                            nodeSelector: {}
                        reports:
                          type: JUnit
                          spec:
                            paths: []
                        outputVariables: []
                        envVariables: {}
                      timeout: 1h
            tags: {}
        - stage:
            name: Deploy
            identifier: Deploy
            description: ""
            type: Deployment
            spec:
              deploymentType: Kubernetes
              service:
                serviceRef: service
              environment:
                environmentRef: Dev
                deployToAll: false
                infrastructureDefinitions:
                  - identifier: Infra
              execution:
                steps:
                  - step:
                      type: Container
                      name: ServiceNow change
                      identifier: ServiceNow_change
                      spec:
                        connectorRef: docker_connector # harness docker connector
                        image: servicenowdocker/sndevops:5.1.0
                        command: |-
                          # set mandetory variables. These can be set from Environment variable section of Optional configuration as well.
                          export HARNESS_STAGE_NAME="<+stage.identifier>"
                          export SNOW_URL="<+variable.SNOW_URL>"
                          export SNOW_TOOLID="<+variable.SNOW_TOOLID>"
                          export SNOW_TOKEN="<+variable.SNOW_TOKEN>"
                          # "sndevopscli create change" command notifies ServiceNow DevOps to create a change. 
                          # Ensure to update "upstreamStage" accordingly. Example, if you have 3 stages Test, Change and Deploy in your pipeline, then you must update as "upstreamStage": "<+pipeline.stages.Test.nodeExecutionId>". Note that if your change stage is the first stage, you can remove this line.
                          sndevopscli create change -ctx \
                          "{
                              \"pipelineExecutionUrl\":\"<+pipeline.executionUrl>\",
                              \"stageIdentifier\": \"<+stage.identifier>\",
                              \"stageNodeExecutionId\": \"<+stage.nodeExecutionId>\",
                              \"pipelineName\": \"<+pipeline.name>\",
                              \"upstreamStage\": \"<+pipeline.stages.ServiceNow_DevOps_Security_Scan_Results.nodeExecutionId>\"
                          }" -p \
                          "{
                              \"changeStepDetails\":
                              {
                                      \"timeout\":3600,
                                      \"interval\":100
                              },
                              \"autoCloseChange\":true,
                              \"attributes\":{
                                  \"chg_model\":\"adffaa9e4370211072b7f6be5bb8f2ed\",
                                  \"short_description\":\"Software Deployment\",
                                  \"description\":\"Automated Software Deployment.\",
                                  \"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",
                                  \"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",
                                  \"test_plan\":\"Testing if the software was successfully deployed or not\"
                              }
                          }"
                        shell: Sh
                        infrastructure:
                          type: KubernetesDirect
                          spec:
                            connectorRef: KUBE_CONNECTOR # harness kubernates connector
                            namespace: harness-delegate-ng
                            resources:
                              limits:
                                cpu: "0.5"
                                memory: 500Mi
                            annotations: {}
                            labels: {}
                            containerSecurityContext:
                              capabilities:
                                drop: []
                                add: []
                            nodeSelector: {}
                        reports:
                          type: JUnit
                          spec:
                            paths: []
                        outputVariables: []
                        envVariables: {}
                      timeout: 1h
                  - step:
                      type: ShellScript
                      name: ShellScript_1
                      identifier: ShellScript_1
                      spec:
                        shell: Bash
                        executionTarget: {}
                        source:
                          type: Inline
                          spec:
                            script: echo "Deploying.."
                        environmentVariables: []
                        outputVariables: []
                      timeout: 10m
                rollbackSteps: []
            tags: {}
            failureStrategies:
              - onFailure:
                  errors:
                    - AllErrors
                  action:
                    type: StageRollback
      properties:
        ci:
          codebase:
            connectorRef: CI_CONNECTOR
            repoName: REPO_NAME
            build: <+input>
            sparseCheckout: []
      notificationRules:
        - name: devopsbugbashwp5
          identifier: devopsbugbashwp5
          pipelineEvents:
            - type: AllEvents
          notificationMethod:
            type: Webhook
            spec:
              webhookUrl: https://{instance_url}/api/sn_devops/v2/devops/tool/orchestration?toolId={tool sys id}&projectId={project sys id}&ni.nolog.token={token}
          enabled: true
    주:
    동일한 단계에서 Sonar 스캔 결과와 보안 스캔 결과를 추가하려면 sn_devops_tool_integration_configuration 테이블의 sonar_step_namessecurity_step_names 필드에서 기본값을 업데이트하여 두 사용자 지정 작업에 서로 다른 단계 이름을 사용할 수 있습니다.