Commit 08bd0bdc authored by Denis Konovalyenko's avatar Denis Konovalyenko

#25: Bitbucket build status update clarified.

parent 1f022fc1
......@@ -9,21 +9,18 @@
# - release
#
# The status stage jobs:
# - success
# - snapshot-success
# - failure
#
# On pushing to the code repository the "verification" job is run.
# If during any job run, except the "snapshot-success" and "success" ones,
# If during any job run, except the "snapshot-success" one,
# a failure occurs, the "failure" 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 the "snapshot" job run succeeded, the "snapshot-success"
# job is run.
#
stages:
......@@ -52,8 +49,9 @@ verification:
- ${HOME}/.m2/repository/
- ${HOME}/target/
script:
- BUILD_STATUS=running BUILD_KEY=push ${CI_GITLAB_PATH}/build-status
- BUILD_STATUS=running ${CI_GITLAB_PATH}/build-status
- mvn verify ${MAVEN_CLI_OPTS}
- BUILD_STATUS=passed ${CI_GITLAB_PATH}/build-status
.deployment: &deployment
stage: deployment
......@@ -64,12 +62,14 @@ verification:
- ${HOME}/target/
policy: pull
script:
- BUILD_STATUS=running ${CI_GITLAB_PATH}/build-status
- 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}
- mvn deploy ${MAVEN_CLI_OPTS} -DskipITs -Dmaven.test.skip=true --activate-profiles sign_and_deploy,release #--quiet
- BUILD_STATUS=passed ${CI_GITLAB_PATH}/build-status
snapshot:
<<: *deployment
......@@ -98,7 +98,9 @@ release:
snapshot-success:
<<: *status
script:
- BUILD_STATUS=running ${CI_GITLAB_PATH}/build-status
- curl -X POST -F token=${OKAPI_TRIGGER_TOKEN} -F ref=${OKAPI_SNAPSHOTS_BRANCH} https://gitlab.com/api/v4/projects/${OKAPI_PROJECT_ID}/trigger/pipeline
- BUILD_STATUS=passed ${CI_GITLAB_PATH}/build-status
only:
variables:
- $SNAPSHOTS_BRANCH == $CI_COMMIT_REF_NAME
......@@ -107,14 +109,8 @@ snapshot-success:
- 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
- BUILD_STATUS=failed ${CI_GITLAB_PATH}/build-status
when: on_failure
......@@ -21,20 +21,23 @@ 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/$CI_JOB_NAME"
BITBUCKET_NAME="$CI_JOB_STAGE:$CI_JOB_NAME:$BUILD_STATUS"
BITBUCKET_DESCRIPTION="Pipeline #$CI_PIPELINE_ID"
GITLAB_URL=$CI_JOB_URL
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."
BITBUCKET_NAME="Pipeline #$CI_PIPELINE_ID"
BITBUCKET_DESCRIPTION="A pipeline job has failed. It should be shown as running now."
GITLAB_URL=$CI_PIPELINE_URL
;;
esac
......@@ -43,5 +46,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\": \"$GITLAB_URL\" }"
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