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

Convert Azure Pipeline to Actions #3

Open
mouismail opened this issue Jun 3, 2024 · 0 comments
Open

Convert Azure Pipeline to Actions #3

mouismail opened this issue Jun 3, 2024 · 0 comments

Comments

@mouismail
Copy link
Owner

Convert azure pipeline to github actions

trigger: none # this pipeline is triggered manually, maybe with a scheduled trigger defined in the Web Editor
variables:
  - name: build_pool
    value: "JUP-DEERL-IPS-VS-HMI-RT-LBA-1"
  - name: linux_image
    value: "captain.rtf.siemens.net:8443/rtng_unified/wincc-bullseye:11.0.58"

jobs:
  - job: GenerateMatrix
    displayName: list agents to inspect
    pool: ${{ variables.build_pool }}
    container:
      image: ${{ variables.linux_image }}
      endpoint: 'docker-registry'
    timeoutInMinutes: 5
    steps:
    - bash: |
        set -euo pipefail
        [[ -z "${AGENT_DIAGNOSTIC+x}" ]] || set -x # enable diagnostics for inline script
        # init list of legs to later compose into a matrix:
        declare -a legs=()
        # list of agents to scan has to be specified as build pipeline variable (we'll put a list of all existing agents as its default)
        for agent in $(AgentsToInspect); do
            # create a matrix with one leg for each agent. The job to inspect an agent will run on each of these:
            legs+=("'${agent}':{'agent':'${agent}'}")
        done
        # print the matrix to make it an output variable accessible from the other job (splitting up the ##vso keyword to prevent parsing issues with set -x active)
        printf "%svso[task.setVariable variable=legs;isOutput=true]{%s}\n" "##" "$(printf "%s," "${legs[@]}")"
      displayName: Calculate matrix to execute
      name: mtrx

  # inspect all the agents calculated above:
  - job: Inspect
    displayName: inspect
    dependsOn: GenerateMatrix
    strategy:
      maxParallel: 999
      matrix: $[ dependencies.GenerateMatrix.outputs['mtrx.legs'] ]
    pool:
      name: ${{ variables.build_pool }}
      demands:
        - Agent.Name -equals $(agent)
    container:
      image: ${{ variables.linux_image }}
      endpoint: 'docker-registry'
    timeoutInMinutes: 2
    steps:
    - checkout: none

    # checking that Artifact Staging Directory can be used (exists and files can be created):
    - bash: |
        set -euo pipefail
        warn() {
            printf "%svso[task.logissue type=error]%s\n" "##" "$*"
            printf "%svso[task.complete result=Failed;]\n" "##"
        }
        die() {
            warn "$@"
            return 1
        }
        date
        set -x # always show details of execution.
        [[ -d "$(Agent.WorkFolder)" ]] || warn "Cannot access the agent Workfolder!"
        ls -la  "$(Agent.WorkFolder)" || warn "Cannot list content of the agent Workfolder!"
        [[ -d "$(Build.ArtifactStagingDirectory)" ]] || warn "Cannot access the Artifact Staging Directory!"
        ls -la "$(Build.ArtifactStagingDirectory)" || warn "Cannot list content of Artifact Staging Directory!"
        touch "$(Build.ArtifactStagingDirectory)/$(agent).log" || die "Cannot create a log file in Artifact Staging Directory!"
        ls -la "$(Build.ArtifactStagingDirectory)"
      displayName: verify Artifact Staging Directory is accessible
      condition: always()
    - task: PublishBuildArtifacts@1
      inputs:
        pathToPublish: '$(Build.ArtifactStagingDirectory)'
        artifactName: 'ArtifactStagingDirectory'
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