Loading .gitlab-ci.yml +54 −8 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ stages: - 1_setup - 2_lint - 3_build - 4_test - 4_validate - 5_release - 6_cleanup - 7_publish Loading Loading @@ -82,7 +82,7 @@ job_readybake_rpmbuild: - env | grep READYBAKE_ || true - mkdir -p ./readybake_cache - docker rmi --force readybake_rpmbuild:latest - docker load < ./readybake_cache/readybake_rpmbuild.tar || rc="$?" - docker load < ./readybake_cache/docker_readybake_rpmbuild.tar || rc="$?" - echo "rc is ${rc}" - echo "READYBAKE_CACHE_REBUILD is $READYBAKE_CACHE_REBUILD" - | Loading Loading @@ -179,6 +179,56 @@ job_rpmbuild: - { when: always } job_tag_validate: stage: 4_validate allow_failure: false tags: [ acme-conda-stage.sns.gov ] script: - pwd - | ls -lah ./rpmbuild ls -lah ./rpmbuild/RPMS/noarch ls -lah ./rpmbuild/SOURCES ls -lah ./rpmbuild/SRPMS # Use the rpm utils inside the readybake_rpmbuild container to retrieve # the package version from the RPM that was generated during stage 3 - test $(find ./rpmbuild/RPMS/ -name "*.rpm" | wc -l) -eq 1 - read -r rpm_file <<< $(find ./rpmbuild/RPMS/ -name "*.rpm") - read -r container_id <<< $(docker create --rm --tty readybake_rpmbuild:latest rpm --query --queryformat='%{version}\n' ${rpm_file}) - docker cp ./rpmbuild ${container_id}:/home/hardhat # read stdout from the container, strip all newlines, carriage returns, tabs, spaces # and store it in pkg_version variable - read -r pkg_version <<< $(docker start --attach ${container_id} | tr -d '\r\n\t ') - tag_release="v${pkg_version}" - tag_list="$(git tag -l | tr '\r\n\t' ' ')" - | echo . echo . echo "nsd-app-wrap validate release tag >> [Info] << git_branch: ${CI_COMMIT_REF_NAME}" echo . echo . echo "nsd-app-wrap validate release tag >> [Info] << git tag -l" echo "${tag_list}" | tr ' ' '\n' echo . echo . echo "nsd-app-wrap validate release tag >> [Info] << tag_release: ${tag_release}" | cat -v echo . echo . # Tag is determined from the rpm spec file. If the version already exists, then error_exit - | if echo -n "${tag_list}" | grep -F -q -w "${tag_release}" ; then echo "nsd-app-wrap validate release tag >> [Error] << tag already exists: ${tag_release}" exit 1 fi echo . echo . needs: - { job: job_rpmbuild } rules: - { when: always } job_tag_release: stage: 5_release allow_failure: false Loading Loading @@ -234,12 +284,7 @@ job_tag_release: # read stdout from the container, strip all newlines, carriage returns, tabs, spaces # and store it in pkg_version variable - read -r pkg_version <<< $(docker start --attach ${container_id} | tr -d '\r\n\t ') - | if [[ "${CI_COMMIT_REF_NAME}" == "${CI_DEFAULT_BRANCH}" ]]; then tag_release="v${pkg_version}" else tag_release="v${pkg_version}-$(date +'%Y%m%d')-${CI_COMMIT_REF_NAME}" fi - tag_release="v${pkg_version}" - tag_list="$(git tag -l | tr '\r\n\t' ' ')" - | echo . Loading Loading @@ -300,6 +345,7 @@ job_docker_cleanup_failure: - { job: job_lint_precommit, optional: true } - { job: job_lint_rpmspec, optional: true } - { job: job_rpmbuild, optional: true } - { job: job_tag_validate, optional: true } - { job: job_tag_release, optional: true } rules: - { when: on_failure } Loading Loading
.gitlab-ci.yml +54 −8 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ stages: - 1_setup - 2_lint - 3_build - 4_test - 4_validate - 5_release - 6_cleanup - 7_publish Loading Loading @@ -82,7 +82,7 @@ job_readybake_rpmbuild: - env | grep READYBAKE_ || true - mkdir -p ./readybake_cache - docker rmi --force readybake_rpmbuild:latest - docker load < ./readybake_cache/readybake_rpmbuild.tar || rc="$?" - docker load < ./readybake_cache/docker_readybake_rpmbuild.tar || rc="$?" - echo "rc is ${rc}" - echo "READYBAKE_CACHE_REBUILD is $READYBAKE_CACHE_REBUILD" - | Loading Loading @@ -179,6 +179,56 @@ job_rpmbuild: - { when: always } job_tag_validate: stage: 4_validate allow_failure: false tags: [ acme-conda-stage.sns.gov ] script: - pwd - | ls -lah ./rpmbuild ls -lah ./rpmbuild/RPMS/noarch ls -lah ./rpmbuild/SOURCES ls -lah ./rpmbuild/SRPMS # Use the rpm utils inside the readybake_rpmbuild container to retrieve # the package version from the RPM that was generated during stage 3 - test $(find ./rpmbuild/RPMS/ -name "*.rpm" | wc -l) -eq 1 - read -r rpm_file <<< $(find ./rpmbuild/RPMS/ -name "*.rpm") - read -r container_id <<< $(docker create --rm --tty readybake_rpmbuild:latest rpm --query --queryformat='%{version}\n' ${rpm_file}) - docker cp ./rpmbuild ${container_id}:/home/hardhat # read stdout from the container, strip all newlines, carriage returns, tabs, spaces # and store it in pkg_version variable - read -r pkg_version <<< $(docker start --attach ${container_id} | tr -d '\r\n\t ') - tag_release="v${pkg_version}" - tag_list="$(git tag -l | tr '\r\n\t' ' ')" - | echo . echo . echo "nsd-app-wrap validate release tag >> [Info] << git_branch: ${CI_COMMIT_REF_NAME}" echo . echo . echo "nsd-app-wrap validate release tag >> [Info] << git tag -l" echo "${tag_list}" | tr ' ' '\n' echo . echo . echo "nsd-app-wrap validate release tag >> [Info] << tag_release: ${tag_release}" | cat -v echo . echo . # Tag is determined from the rpm spec file. If the version already exists, then error_exit - | if echo -n "${tag_list}" | grep -F -q -w "${tag_release}" ; then echo "nsd-app-wrap validate release tag >> [Error] << tag already exists: ${tag_release}" exit 1 fi echo . echo . needs: - { job: job_rpmbuild } rules: - { when: always } job_tag_release: stage: 5_release allow_failure: false Loading Loading @@ -234,12 +284,7 @@ job_tag_release: # read stdout from the container, strip all newlines, carriage returns, tabs, spaces # and store it in pkg_version variable - read -r pkg_version <<< $(docker start --attach ${container_id} | tr -d '\r\n\t ') - | if [[ "${CI_COMMIT_REF_NAME}" == "${CI_DEFAULT_BRANCH}" ]]; then tag_release="v${pkg_version}" else tag_release="v${pkg_version}-$(date +'%Y%m%d')-${CI_COMMIT_REF_NAME}" fi - tag_release="v${pkg_version}" - tag_list="$(git tag -l | tr '\r\n\t' ' ')" - | echo . Loading Loading @@ -300,6 +345,7 @@ job_docker_cleanup_failure: - { job: job_lint_precommit, optional: true } - { job: job_lint_rpmspec, optional: true } - { job: job_rpmbuild, optional: true } - { job: job_tag_validate, optional: true } - { job: job_tag_release, optional: true } rules: - { when: on_failure } Loading