Commit bfbf320e authored by Denis Konovalyenko's avatar Denis Konovalyenko

Merged in DenisKonovalyenko/xliff-toolkit/25-build-status (pull request #11)

#25: Bitbucket build status update clarified.
Approved-by: Mihai Nita's avatarMihai Nita <mihnita@gmail.com>
parents 1f022fc1 f338e283
......@@ -8,31 +8,28 @@
# - snapshot
# - release
#
# The status stage jobs:
# - success
# - snapshot-success
# - failure
# The trigger stage jobs:
# - okapi-snapshot-trigger
#
# On pushing to the code repository the "verification" job is run.
# If during any job run, except the "snapshot-success" and "success" ones,
# a failure occurs, the "failure" job is run.
# Normally, on pushing to the code repository the "verification" job is run.
#
# If a branch is a "snapshot branch", then the "snapshot" job is run.
# If a branch is a "tag", then the "release" job is run.
#
# If the "snapshot" job run succeeded, the "success" and "snapshot-success"
# jobs are run.
# If the "verification" job run succeeded and there is no "snapshot" or
# "release" job for this pipeline, the "success" job is run.
# If a branch is a "snapshot branch", then the "okapi-snapshot-trigger"
# job is run.
#
# If any of the jobs fails, no other consequential job is run.
#
stages:
- verification
- deployment
- status
- trigger
variables:
CI_GITLAB_PATH: "ci/gitlab"
CI_SCRIPTS_PATH: "${CI_GITLAB_PATH}/scripts"
MAVEN_IMAGE: "maven:3.5.3-jdk-8"
BASH_CURL_IMAGE: "cosmintitei/bash-curl:latest"
MAVEN_CLI_OPTS: "--settings ${CI_GITLAB_PATH}/.m2/settings.xml --batch-mode --errors --show-version"
......@@ -44,6 +41,11 @@ variables:
SNAPSHOTS_BRANCH: "dev"
# CI_DEBUG_TRACE: "true" # WARNING: all secret variables will be exposed to a job output!
before_script:
- ${CI_SCRIPTS_PATH}/before-job
after_script:
- ${CI_SCRIPTS_PATH}/after-job
verification:
stage: verification
image: ${MAVEN_IMAGE}
......@@ -52,8 +54,8 @@ verification:
- ${HOME}/.m2/repository/
- ${HOME}/target/
script:
- BUILD_STATUS=running BUILD_KEY=push ${CI_GITLAB_PATH}/build-status
- mvn verify ${MAVEN_CLI_OPTS}
- touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
.deployment: &deployment
stage: deployment
......@@ -64,12 +66,9 @@ verification:
- ${HOME}/target/
policy: pull
script:
- openssl ${OPENSSL_CLI_OPTS} -d -in ${CI_GITLAB_PATH}/code-signing-key.asc.enc -out ${CI_GITLAB_PATH}/code-signing-key.asc
- gpg --quiet --batch --import ${CI_GITLAB_PATH}/code-signing-key.asc
- echo "use-agent" > ${HOME}/{GPG_CONF}
- echo "pinentry-mode loopback" >> ${HOME}/${GPG_CONF}
- echo "allow-loopback-pinentry" > ${HOME}/${GPG_AGENT_CONF}
- ${CI_SCRIPTS_PATH}/gpg-import
- mvn deploy ${MAVEN_CLI_OPTS} -DskipITs -Dmaven.test.skip=true --activate-profiles sign_and_deploy,release #--quiet
- touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
snapshot:
<<: *deployment
......@@ -87,34 +86,18 @@ release:
except:
- branches
.status: &status
stage: status
.trigger: &trigger
stage: trigger
image: ${BASH_CURL_IMAGE}
before_script:
- ""
after_script:
- ""
snapshot-success:
<<: *status
okapi-snapshot-trigger:
<<: *trigger
script:
- curl -X POST -F token=${OKAPI_TRIGGER_TOKEN} -F ref=${OKAPI_SNAPSHOTS_BRANCH} https://gitlab.com/api/v4/projects/${OKAPI_PROJECT_ID}/trigger/pipeline
- touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
only:
variables:
- $SNAPSHOTS_BRANCH == $CI_COMMIT_REF_NAME
except:
- tags
- master
when: on_success
success:
<<: *status
script:
- BUILD_STATUS=passed BUILD_KEY=push ${CI_GITLAB_PATH}/build-status
when: on_success
failure:
<<: *status
script:
- BUILD_STATUS=failed BUILD_KEY=push ${CI_GITLAB_PATH}/build-status
when: on_failure
#!/usr/bin/env bash
if [ ! -f ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed ] ; then
BUILD_STATUS=failed ${CI_SCRIPTS_PATH}/build-status;
else
BUILD_STATUS=passed ${CI_SCRIPTS_PATH}/build-status;
fi
#!/usr/bin/env bash
rm -f ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
BUILD_STATUS=running ${CI_SCRIPTS_PATH}/build-status
......@@ -21,20 +21,19 @@ fi
BITBUCKET_API_ROOT="https://api.bitbucket.org/2.0"
BITBUCKET_STATUS_API="$BITBUCKET_API_ROOT/repositories/$BITBUCKET_NAMESPACE/$BITBUCKET_REPOSITORY/commit/$CI_COMMIT_SHA/statuses/build"
BITBUCKET_KEY="ci/gitlab-ci/$CI_JOB_NAME"
BITBUCKET_KEY="$CI_GITLAB_PATH/$CI_JOB_NAME"
BITBUCKET_NAME="$CI_JOB_STAGE:$CI_JOB_NAME:$BUILD_STATUS"
BITBUCKET_DESCRIPTION="Pipeline #$CI_PIPELINE_ID"
case "$BUILD_STATUS" in
running)
BITBUCKET_STATE="INPROGRESS"
BITBUCKET_DESCRIPTION="The build is running!"
;;
passed)
BITBUCKET_STATE="SUCCESSFUL"
BITBUCKET_DESCRIPTION="The build passed!"
;;
failed)
BITBUCKET_STATE="FAILED"
BITBUCKET_DESCRIPTION="The build failed."
;;
esac
......@@ -43,5 +42,8 @@ curl --request POST $BITBUCKET_STATUS_API \
--user $BITBUCKET_USERNAME:$BITBUCKET_ACCESS_TOKEN \
--header "Content-Type:application/json" \
--silent \
--data "{ \"state\": \"$BITBUCKET_STATE\", \"key\": \"$BITBUCKET_KEY\", \"description\":
\"$BITBUCKET_DESCRIPTION\",\"url\": \"$CI_PROJECT_URL/-/jobs/$CI_JOB_ID\" }"
--data "{ \"state\": \"$BITBUCKET_STATE\",
\"key\": \"$BITBUCKET_KEY\",
\"name\": \"$BITBUCKET_NAME\",
\"description\": \"$BITBUCKET_DESCRIPTION\",
\"url\": \"$CI_JOB_URL\" }"
#!/usr/bin/env bash
openssl ${OPENSSL_CLI_OPTS} -d -in ${CI_GITLAB_PATH}/code-signing-key.asc.enc -out ${CI_GITLAB_PATH}/code-signing-key.asc
gpg --quiet --batch --import ${CI_GITLAB_PATH}/code-signing-key.asc
echo "use-agent" > ${HOME}/${GPG_CONF}
echo "pinentry-mode loopback" >> ${HOME}/${GPG_CONF}
echo "allow-loopback-pinentry" > ${HOME}/${GPG_AGENT_CONF}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment