aboutsummaryrefslogtreecommitdiffstats
path: root/jobs/gerrit-binpkgs.yml
blob: 7a4e9e91d3237cc9c1cbe4a37cdb5502565c880c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This file holds all gerrit verifications for building deb and rpm packages.
# https://jenkins.osmocom.org/jenkins/view/Jenkins-Gerrit/.
# One can simply add a gerrit job by adding project's repository to repos list.

- project:
    name: gerrit-binpkgs
    jobs:
      - 'gerrit-binpkgs-{type}'
    type:
      - 'deb'
      - 'rpm'

- job-template:
    name: 'gerrit-binpkgs-{type}'
    project-type: freestyle
    node: osmocom-gerrit
    concurrent: true
    retry-count: 3 # scm checkout
    properties:
      - build-discarder:
          days-to-keep: 30
          num-to-keep: 1000
    description: |
      {type} package job of CI for patches sent to
      <a href="https://gerrit.osmocom.org">gerrit</a>
      </br></br>
      Related issue: <a href="https://osmocom.org/issues/2385">OS#2385</a>

    parameters:
      - string:
          name: BRANCH_CI
          description: |
                osmo-ci.git branch
          default: 'master'
      - string:
          name: GERRIT_REPO_URL
          description: set by gerrit verification pipeline job
      - string:
          name: GERRIT_BRANCH
          description: set by gerrit verification pipeline job
      - string:
          name: GERRIT_REFSPEC
          description: set by gerrit verification pipeline job
      - string:
          name: PROJECT_NAME
          description: project to test, e.g. 'libosmocore' (set by pipeline)

    scm:
      - git:
         basedir: 'code-from-gerrit'
         url: '$GERRIT_REPO_URL'
         credentials-id: d5eda5e9-b59d-44ba-88d2-43473cb6e42d
         branches:
           - $GERRIT_BRANCH
         refspec: $GERRIT_REFSPEC
         name:
         choosing-strategy: gerrit
         wipe-workspace: true
         skip-tag: true
         submodule:
           recursive: false

    builders:
      - shell: |-
          # Skip rpm build if .spec.in file is missing
          if [ "{type}" = "rpm" ] && [ -z "$(find code-from-gerrit -name '*.spec.in')" ]; then
            set +x
            echo
            echo "No *.spec.in file found, skipping rpm build."
            echo
            exit 0
          fi

          # Clone osmo-ci.git
          rm -rf osmo-ci
          git clone \
            --depth=1 \
            --branch="$BRANCH_CI" \
            https://gerrit.osmocom.org/osmo-ci \
            osmo-ci
          git -C osmo-ci log --oneline

          # Get distro from type
          case "{type}" in
          deb) distro="debian:11" ;;
          rpm) distro="almalinux:8" ;;
          *) echo "unknown package format: '{type}'"; exit 1 ;;
          esac

          # Move code from gerrit to build_srcpkg.py's git cache
          cache_dir=osmo-ci/scripts/obs/_cache
          mkdir -p $cache_dir
          mv code-from-gerrit "$cache_dir/$PROJECT_NAME"

          # Set a known branch name
          git -C "$cache_dir/$PROJECT_NAME" checkout -B "origin/gerrit"

          # Build source package
          cd osmo-ci/scripts/obs/
          ./build_srcpkg.py \
            --docker \
            --feed master \
            --git-branch gerrit \
            --git-skip-fetch \
            "$PROJECT_NAME"

          # Build binary package
          ./build_binpkg.py \
            --docker "$distro" \
            "$PROJECT_NAME"
    wrappers:
    - ansicolor:
        colormap: xterm
    - ssh-agent-credentials:
        users:
        - d5eda5e9-b59d-44ba-88d2-43473cb6e42d

# vim: expandtab tabstop=2 shiftwidth=2