Commit cbd71d1c authored by Denis Konovalyenko's avatar Denis Konovalyenko

#25: Bitbucket multiple builds per commit provided.

parent 08bd0bdc
......@@ -8,25 +8,15 @@
# - snapshot
# - release
#
# The status stage jobs:
# - snapshot-success
# - failure
#
# On pushing to the code repository the "verification" job is run.
# 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 "snapshot-success"
# job is run.
#
stages:
- verification
- deployment
- status
variables:
CI_GITLAB_PATH: "ci/gitlab"
......@@ -41,6 +31,11 @@ variables:
SNAPSHOTS_BRANCH: "dev"
# CI_DEBUG_TRACE: "true" # WARNING: all secret variables will be exposed to a job output!
before_script:
- ${CI_GITLAB_PATH}/before-job
after_script:
- ${CI_GITLAB_PATH}/after-job
verification:
stage: verification
image: ${MAVEN_IMAGE}
......@@ -49,9 +44,8 @@ verification:
- ${HOME}/.m2/repository/
- ${HOME}/target/
script:
- BUILD_STATUS=running ${CI_GITLAB_PATH}/build-status
- mvn verify ${MAVEN_CLI_OPTS}
- BUILD_STATUS=passed ${CI_GITLAB_PATH}/build-status
- touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
.deployment: &deployment
stage: deployment
......@@ -62,14 +56,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
- 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
snapshot:
<<: *deployment
......@@ -86,31 +80,3 @@ release:
- tags
except:
- branches
.status: &status
stage: status
image: ${BASH_CURL_IMAGE}
before_script:
- ""
after_script:
- ""
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
except:
- tags
- master
when: on_success
failure:
<<: *status
script:
- BUILD_STATUS=failed ${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_GITLAB_PATH}/build-status;
else
BUILD_STATUS=passed ${CI_GITLAB_PATH}/build-status;
fi
#!/usr/bin/env bash
rm -f ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
BUILD_STATUS=running ${CI_GITLAB_PATH}/build-status
......@@ -35,9 +35,6 @@ passed)
;;
failed)
BITBUCKET_STATE="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
......@@ -50,4 +47,4 @@ curl --request POST $BITBUCKET_STATUS_API \
\"key\": \"$BITBUCKET_KEY\",
\"name\": \"$BITBUCKET_NAME\",
\"description\": \"$BITBUCKET_DESCRIPTION\",
\"url\": \"$GITLAB_URL\" }"
\"url\": \"$CI_JOB_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