blob: c54e0ef7e7feb4c4974978ee8b2e40e19599a75e [file] [log] [blame]
Fatih Degirmenci46838e22018-05-18 19:01:25 +02001#!/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##############################################################################
10set -o errexit
11set -o nounset
12set -o pipefail
13
Fatih Degirmenci9eb9d2d2018-09-20 15:38:12 +020014# workaround for https://github.com/pypa/virtualenv/issues/1029
15export PS1=${PS1:-}
Fatih Degirmenci46838e22018-05-18 19:01:25 +020016
Fatih Degirmenci9eb9d2d2018-09-20 15:38:12 +020017# This script creates ArtifactPublishedEvent (APE)
18
19git clone https://gitlab.openci.io/openci/prototypes.git
20cd prototypes/federated-cicd
21virtualenv openci_publish
22cd openci_publish
23source bin/activate
24python setup.py install
25
26# generate event body
27cat <<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 Degirmenci46838e22018-05-18 19:01:25 +020038EOF
Fatih Degirmenci9eb9d2d2018-09-20 15:38:12 +020039
40python openci_publish -H 129.192.69.55 -U ${ACTIVEMQ_USER} -p ${ACTIVEMQ_PASSWORD} -n openci.prototype -B ./json_body.txt
41
Fatih Degirmenci46838e22018-05-18 19:01:25 +020042echo "Constructed $PUBLISH_EVENT_TYPE"
43echo "--------------------------------------------"
Fatih Degirmenci9eb9d2d2018-09-20 15:38:12 +020044cat ./json_body.txt
Fatih Degirmenci46838e22018-05-18 19:01:25 +020045echo "--------------------------------------------"
Fatih Degirmenci9eb9d2d2018-09-20 15:38:12 +020046
47deactivate