Fatih Degirmenci | 46838e2 | 2018-05-18 19:01:25 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # SPDX-license-identifier: Apache-2.0 |
| 3 | ############################################################################## |
| 4 | # Copyright (c) 2018 Ericsson AB and others. |
| 5 | # All rights reserved. This program and the accompanying materials |
| 6 | # are made available under the terms of the Apache License, Version 2.0 |
| 7 | # which accompanies this distribution, and is available at |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ############################################################################## |
| 10 | set -o errexit |
| 11 | set -o nounset |
| 12 | set -o pipefail |
| 13 | |
Fatih Degirmenci | 9eb9d2d | 2018-09-20 15:38:12 +0200 | [diff] [blame] | 14 | # workaround for https://github.com/pypa/virtualenv/issues/1029 |
| 15 | export PS1=${PS1:-} |
Fatih Degirmenci | 46838e2 | 2018-05-18 19:01:25 +0200 | [diff] [blame] | 16 | |
Fatih Degirmenci | 9eb9d2d | 2018-09-20 15:38:12 +0200 | [diff] [blame] | 17 | # This script creates ArtifactPublishedEvent (APE) |
| 18 | |
| 19 | git clone https://gitlab.openci.io/openci/prototypes.git |
| 20 | cd prototypes/federated-cicd |
| 21 | virtualenv openci_publish |
| 22 | cd openci_publish |
| 23 | source bin/activate |
| 24 | python setup.py install |
| 25 | |
| 26 | # generate event body |
| 27 | cat <<EOF > ./json_body.txt |
| 28 | { |
| 29 | "type": "$PUBLISH_EVENT_TYPE", |
| 30 | "id": "$(uuidgen)", |
| 31 | "time": "$(date -u +%Y-%m-%d_%H:%M:%SUTC)", |
| 32 | "buildUrl": "$BUILD_URL", |
| 33 | "branch": "master", |
| 34 | "origin": "$PUBLISH_EVENT_ORIGIN", |
| 35 | "artifactLocation": "$ARTIFACT_LOCATION", |
| 36 | "confidenceLevel": "$CONFIDENCE_LEVEL" |
| 37 | } |
Fatih Degirmenci | 46838e2 | 2018-05-18 19:01:25 +0200 | [diff] [blame] | 38 | EOF |
Fatih Degirmenci | 9eb9d2d | 2018-09-20 15:38:12 +0200 | [diff] [blame] | 39 | |
Fatih Degirmenci | 46838e2 | 2018-05-18 19:01:25 +0200 | [diff] [blame] | 40 | echo "Constructed $PUBLISH_EVENT_TYPE" |
| 41 | echo "--------------------------------------------" |
Fatih Degirmenci | 9eb9d2d | 2018-09-20 15:38:12 +0200 | [diff] [blame] | 42 | cat ./json_body.txt |
Fatih Degirmenci | 46838e2 | 2018-05-18 19:01:25 +0200 | [diff] [blame] | 43 | echo "--------------------------------------------" |
Fatih Degirmenci | 9eb9d2d | 2018-09-20 15:38:12 +0200 | [diff] [blame] | 44 | |
Fatih Degirmenci | f84a820 | 2018-09-21 09:48:02 +0200 | [diff] [blame] | 45 | python openci_publish -H 129.192.69.55 -U ${ACTIVEMQ_USER} -p ${ACTIVEMQ_PASSWORD} -n openci.prototype -B ./json_body.txt |
| 46 | |
Fatih Degirmenci | 9eb9d2d | 2018-09-20 15:38:12 +0200 | [diff] [blame] | 47 | deactivate |