summaryrefslogtreecommitdiff
path: root/jenkins/trigger-job
blob: 4fff3a5007090c2dcb205007faeba9896a84edb4 (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
#!/bin/sh

# ./trigger-job -g debian apgdiff
# ./trigger-job -b 'Rebuild against python 3.8' -d bullseye postgresql-12-binaries
# ./trigger-job dput 'binaries=postgresql-12-binaries'

# ~/.netrc:
#machine jengus.postgresql.org login <username> password <your-api-token>

set -e

while getopts "Aa:b:B:d:g:nq:r:u" opt ; do
  case $opt in
    A) autopkgtest="autopkgtest=skip" ;;
    a) architecture="architecture==\"$OPTARG\"" ;;
    b) binnmu_reason="binnmu_reason=$OPTARG"
      : ${binnmu_version:=binnmu_version=1} ;;
    B) binnmu_version="binnmu_version=$OPTARG" ;;
    d) distribution="distribution in [\"$OPTARG\"]" ;;
    g) branch="branch=$OPTARG" ;;
    n) DEB_BUILD_OPTIONS="DEB_BUILD_OPTIONS=nocheck" ;;
    q) queue="queue=$OPTARG" ;;
    r) revision="revision=$OPTARG" ;;
    u) upload="upload=extension-only" ;;
    *) exit 5 ;;
  esac
done
# shift away args
shift $(($OPTIND - 1))

JOB="$1"
shift

if [ "$architecture" ] && [ "$distribution" ]; then
  matrix="matrix=$architecture%26%26$distribution"
elif [ "$architecture" ]; then
  matrix="matrix=$architecture"
elif [ "$distribution" ]; then
  matrix="matrix=$distribution"
fi

IFS="&"
set -- $branch $revision $binnmu_reason $binnmu_version $autopkgtest $DEB_BUILD_OPTIONS $queue $upload $matrix "$@" token=buildnow

set -x
curl -f --netrc \
  "https://jengus.postgresql.org/job/$JOB/buildWithParameters" \
  --data "$*"

#for JOB in $JOB{,-source,-binaries,-autopkgtest,-autopkgtest-beta,-source-snapshot,-binaries-snapshot}; do
#curl --netrc -X POST "https://jengus.postgresql.org/job/$JOB/doDelete"
#done