Uh, this is a rediculously old mess of notes from a long time ago before I was familiar with GitLab CI pipelines. I don’t really know why I have kept this. It’s not helpful. I’m a data hoarder though.
variables:
CI_DEBUG_TRACE: "true"
GIT_CURL_VERBOSE: "1"
GIT_DEBUG_LOOKUP: "1"
GIT_TRACE: "1"
GIT_TRACE_PACKET: "1"
GIT_TRANSLOOP_DEBUG: "1"
GIT_TRANSPORT_HELPER_DEBUG: "1"
pkg: "my-awesome-project"
artifactory_api: "https://artifactory.local"
artifactory_repo: "test-rpm-local"
artifactory_user: "gitlab-ci"
#artifactory_secret is defined under Settings > CI/CD Pipelines > Secret Variables.
image: nicolaw/docker-shellci
stages:
- test
- build
- deploy
build:
stage: build
script:
- VERSION="$(< VERSION)"
- mkdir -pv "build/${pkg}-${VERSION%.*}"
- cp -v *.* Makefile CHANGELOG LICENSE "build/${pkg}-${VERSION%.*}"
- tar -C build/ -zvcf "${pkg}-${VERSION}.tar.gz" "${pkg}-${VERSION%.*}"
- >
rpmbuild -ba "build/${pkg}-${VERSION%.*}/${pkg}.spec"
--define "name ${pkg}"
--define "version ${VERSION%.*}"
--define "release ${VERSION##*.}"
--define "_sourcedir $PWD"
--define "_rpmdir $PWD"
--define "_build_name_fmt {VERSION}-{ARCH}.rpm"
artifacts:
untracked: true
paths:
- build/
- "*.rpm"
- "*.tar.gz"
when: on_success
expire_in: 1 week
unit tests:
stage: test
script:
- make test
coverage: '/\d+\.\d+% coverage/'
deploy to staging:
stage: deploy
when: manual
variables:
environment: staging
environment:
name: staging
script: &deploy_to_artifactory
- >
for rpm in *.rpm ; do
curl "-u${artifactory_user}:${artifactory_secret}"
-XPUT "${artifactory_api}/${artifactory_repo}/${environment}/${rpm##*/}"
-T "${rpm}" ;
done
- curl "-u${artifactory_user}:${artifactory_secret}"
-POST "${artifactory_api}/${artifactory_repo}?path=${environment}&async=1"
deploy to production:
stage: deploy
when: manual
variables:
environment: production
environment:
name: production
script: *deploy_to_artifactory