summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@verizonmedia.com>2023-03-27 20:41:31 +0200
committerGitHub <noreply@github.com>2023-03-27 20:41:31 +0200
commit599c317f3dbebecb2de0dba246c6c78c5400bcd0 (patch)
treec9d1ffc52f7813f08c090457fbd5f5cba9af12b5
parent1a380a5e64d2098e35c86d3bd83f88858875a18e (diff)
parentacc66ba9d3f5ac6ad1961745695a5a57d5b07022 (diff)
Merge pull request #26594 from vespa-engine/aressem/integrate-with-factory
Create and reports builds from cd.screwdriver.cd
-rw-r--r--screwdriver.yaml30
-rwxr-xr-xscrewdriver/factory-command.sh73
2 files changed, 98 insertions, 5 deletions
diff --git a/screwdriver.yaml b/screwdriver.yaml
index e54d9c2abb0..4740d8d75ef 100644
--- a/screwdriver.yaml
+++ b/screwdriver.yaml
@@ -105,11 +105,13 @@ jobs:
CCACHE_COMPRESS: "1"
secrets:
- DOCKER_HUB_DEPLOY_KEY
+ - SVC_OKTA_VESPA_FACTORY_TOKEN
steps:
- get-vespa-version: |
- VESPA_VERSION=$(meta get vespa.version)
- VESPA_REF=$(meta get vespa.ref)
- SYSTEM_TEST_REF=$(meta get system-test.ref)
+ VERSION_INFO=$(screwdriver/factory-command.sh create-build)
+ VESPA_VERSION=$(jq -re '.version' <<< "$VERSION_INFO")
+ VESPA_REF=$(jq -re '.commits|.[]|select(.repo=="vespa")|.ref' <<< "$VERSION_INFO")
+ SYSTEM_TEST_REF=$(jq -re '.commits|.[]|select(.repo=="system-test")|.ref' <<< "$VERSION_INFO")
if [[ $VESPA_VERSION == null ]] || [[ $VESPA_REF == null ]] || [[ $SYSTEM_TEST_REF == null ]]; then
echo "Must have valid Vespa version and reference to continue \
(got VESPA_VERSION=$VESPA_VERSION, VESPA_REF=$VESPA_REF, SYSTEM_TEST_REF=$SYSTEM_TEST_REF)."
@@ -184,6 +186,18 @@ jobs:
buildah push --format v2s2 docker.io/vespaengine/vespa-systemtest-centos-stream8:$VESPA_VERSION docker://docker.io/vespaengine/vespa-systemtest-centos-stream8:latest
fi
- *save-cache
+ - update-build-status: |
+ meta set vespa.factory.build.status $FACTORY_BUILD_STATUS
+ - teardown-report-build-status: |
+ FACTORY_BUILD_STATUS=$(meta get vespa.factory.build.status)
+ if [[ $FACTORY_BUILD_STATUS == success ]]; then
+ DESCRIPTION="Build success"
+ else
+ FACTORY_BUILD_STATUS=failure
+ DESCRIPTION="Build failed"
+ fi
+ echo "Reporting build status as $FACTORY_BUILD_STATUS"
+ $SD_SOURCE_DIR/screwdriver/factory-command.sh update-build-status $FACTORY_BUILD_STATUS "$DESCRIPTION"
publish-release:
image: docker.io/vespaengine/vespa-build-centos-stream8:latest
@@ -209,14 +223,18 @@ jobs:
- DOCKER_IMAGE_DEPLOY_KEY
- DOCKER_HUB_DEPLOY_KEY
- GHCR_DEPLOY_KEY
+ - SVC_OKTA_VESPA_FACTORY_TOKEN
environment:
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
steps:
- get-vespa-version: |
- VESPA_VERSION=$(meta get vespa.version)
- VESPA_REF=$(meta get vespa.ref)
+ JSON=$(screwdriver/factory-command.sh create-release)
+ VESPA_VERSION=$(jq -re '.version' <<< "$JSON")
+ JSON=$(screwdriver/factory-command.sh get-version $VESPA_VERSION)
+ VESPA_REF=$(jq -re '.commits|.[]|select(.repo=="vespa")|.ref' <<< "$JSON")
+ echo "VESPA_VERSION=$VESPA_VERSION VESPA_REF=$VESPA_REF"
if [[ $VESPA_VERSION == null ]] || [[ $VESPA_REF == null ]]; then
echo "Must have valid Vespa version and reference to continue (got VESPA_VERSION=$VESPA_VERSION, VESPA_REF=$VESPA_REF)."
return 1
@@ -231,6 +249,8 @@ jobs:
screwdriver/release-container-image.sh $VESPA_VERSION
- update-sample-apps: |
screwdriver/update-vespa-version-in-sample-apps.sh $VESPA_VERSION
+ - update-released-time: |
+ screwdriver/factory-command.sh update-released-time
publish-legacy-release:
image: docker.io/vespaengine/vespa-build-centos-stream8:latest
diff --git a/screwdriver/factory-command.sh b/screwdriver/factory-command.sh
new file mode 100755
index 00000000000..b938b36d8e8
--- /dev/null
+++ b/screwdriver/factory-command.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+set -eo pipefail
+
+if (( $# < 1 )); then
+ echo "Usage: $0 <command> [options]"
+ exit 1
+fi
+
+COMMAND=$1
+FACTORY_API="https://factory.vespa.aws-us-east-1a.vespa.oath.cloud/api/factory/v1"
+COOKIEJAR=$(pwd)/jar.txt
+trap "rm -f $COOKIEJAR" EXIT
+
+SESSION_TOKEN=$(curl -s -H 'Content-Type: application/json' -H 'Accept: application/json' -d "{ \"username\": \"svc-okta-vespa-factory\", \"password\": \"$SVC_OKTA_VESPA_FACTORY_TOKEN\" }" https://ouryahoo.okta.com/api/v1/authn | jq -re '.sessionToken')
+LOCATION=$(curl -s -i -c $COOKIEJAR "https://factory.vespa.aws-us-east-1a.vespa.oath.cloud/login" | grep location | awk '{print $2}' | tr -d '\r')
+curl -sL -b $COOKIEJAR -c $COOKIEJAR "$LOCATION&sessionToken=$SESSION_TOKEN" &> /dev/null
+
+CURL="curl -sL -b $COOKIEJAR"
+
+shift
+case $COMMAND in
+ get-version)
+ VERSION=$1
+ if [[ -z $VERSION ]]; then echo "Usage: $0 $COMMAND <version>"; exit 1; fi
+ $CURL "$FACTORY_API/versions/$VERSION"
+ ;;
+ create-build)
+ $CURL -d "{
+ \"startSeconds\": $(date +%s),
+ \"sdApiUrl\": \"https://api.screwdriver.cd/v4/\",
+ \"pipelineId\": $SD_PIPELINE_ID,
+ \"jobId\": $SD_JOB_ID,
+ \"buildId\": $SD_BUILD_ID,
+ \"platform\": \"opensource_centos7\"
+ }" \
+ "$FACTORY_API/builds"
+ ;;
+ create-release)
+ $CURL -d "{
+ \"startSeconds\": $(date +%s),
+ \"systemName\": \"opensource\"
+ }" \
+ "$FACTORY_API/releases"
+ ;;
+ update-build-status)
+ STATUS=$1
+ DESCRIPTION=$2
+ if [[ -z $STATUS ]] || [[ -z $DESCRIPTION ]]; then echo "Usage: $0 $COMMAND <status> <description>"; exit 1; fi
+ $CURL -d "{
+ \"updatedSeconds\": $(date +%s),
+ \"sdApiUrl\": \"https://api.screwdriver.cd/v4/\",
+ \"pipelineId\": $SD_PIPELINE_ID,
+ \"jobId\": $SD_JOB_ID,
+ \"buildId\": $SD_BUILD_ID,
+ \"status\": \"$STATUS\",
+ \"description\": \"$DESCRIPTION\"
+ }" \
+ "$FACTORY_API/builds/$SD_BUILD_ID/status"
+ ;;
+ update-released-time)
+ VERSION=$1
+ if [[ -z $VERSION ]]; then echo "Usage: $0 $COMMAND <version>"; exit 1; fi
+ $CURL -d "{
+ \"releasedSeconds\": $(date +%s),
+ \"systemName\": \"opensource\"
+ }" \
+ "$FACTORY_API/releases/$VERSION"
+ ;;
+ *)
+ echo "Unknown command $COMMAND"
+ exit 1
+ ;;
+esac