* 目次 [#i097eb1f] #contents ** JHipsterのCI/CDのページ [#x83b0348] https://www.jhipster.tech/setting-up-ci/ ** GitLabのCI/CDのページ [#ofc55fbb] https://about.gitlab.com/features/continuous-integration/ ** .gitlab-ci.yml ファイルとは [#e450d961] .gitlab-ci.yml ファイルはパイプラインの構造と順序を定義し、以下のことを決めます。 - GitLab Runnerを使って実行する内容。 - 特定の状況において、どのような判断をするか。例えば、処理が成功した場合と失敗した場合。 ** .gitlab-ci.ymlのリファレンス [#h1cf516a] https://gitlab-docs.creationline.com/ee/ci/yaml/ *** GitLabのクイックスタート [#xee0cfc6] https://gitlab-docs.creationline.com/ee/ci/quick_start/README.html ** GitLabの設定サンプル [#dd8c86af] https://gitlab-docs.creationline.com/ee/ci/examples/README.html *** mavenを使った例 [#z4fd2745] https://gitlab-docs.creationline.com/ee/ci/examples/artifactory_and_gitlab/index.html *** spring-bootを使った例 [#pa163e7d] https://gitlab-docs.creationline.com/ee/ci/examples/deploy_spring_boot_to_cloud_foundry/index.html ** jhipster ci-cdをためす [#bcee8a31] jhipster ci-cd を実行してみる 選択枝でGitLabを選ぶ In GitLab CI, perform the build in a docker container となる。 y を選ぶ .gitlab-ci.yml が変更になる ** .gitlab-ci.yml に追加されたコード [#z53e08e5] 追加のタスクは何もなしで進むと以下のコードが追加された image: jhipster/jhipster:v7.9.3 cache: key: '$CI_COMMIT_REF_NAME' paths: - .maven/ stages: - check - build - test - analyze - package - release - deploy before_script: - export MAVEN_USER_HOME=`pwd`/.maven nohttp: stage: check script: - ./mvnw -ntp checkstyle:check -Dmaven.repo.local=$MAVEN_USER_HOME maven-compile: stage: build script: - ./mvnw -ntp compile -P-webapp -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: paths: - target/classes/ - target/generated-sources/ expire_in: 1 day maven-test: services: - docker:dind variables: # Instruct Testcontainers to use the daemon of DinD. DOCKER_HOST: 'tcp://docker:2375' # Improve performance with overlayfs. DOCKER_DRIVER: overlay2 stage: test script: - ./mvnw -ntp verify -P-webapp -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: reports: junit: - target/surefire-reports/TEST-*.xml - target/failsafe-reports/TEST-*.xml paths: - target/surefire-reports - target/failsafe-reports - target/site expire_in: 1 day frontend-test: stage: test script: - npm install - npm test artifacts: reports: junit: target/test-results/TESTS-results-jest.xml paths: - target/test-results - target/jacoco expire_in: 1 day maven-package: stage: package script: - ./mvnw -ntp verify -Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: paths: - target/*.jar - target/classes expire_in: 1 day # Uncomment the following line to use gitlabs container registry. You need to adapt the REGISTRY_URL in case you are not using gitlab.com #docker-push: # stage: release # variables: # REGISTRY_URL: registry.gitlab.com # IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA # dependencies: # - maven-package # script: # - ./mvnw -ntp jib:build -Pprod -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=gitlab-ci-token -Djib.to.auth.password=$CI_BUILD_TOKEN -Dmaven.repo.local=$MAVEN_USER_HOME * GitLab Runnerは別サーバー? [#qef7020e] もしかしてGitLabRunnerは別サーバにたてるのだろうか? 以下に構築方法を解説しているサイトがあった。 https://www.alpha.co.jp/blog/202208_01#%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E3%82%A2%E3%83%BC%E3%83%86%E3%82%A3%E3%83%95%E3%82%A1%E3%82%AF%E3%83%88%E3%83%AC%E3%82%B8%E3%82%B9%E3%83%88%E3%83%AA%E3%81%AE%E6%A0%BC%E7%B4%8D%E5%A0%B4%E6%89%80 * Dockerコンテナでgitlabとgitlab-runnerを構築してCI/CD [#j72672bb] https://syachiku.net/docker-gitlab-gitlab-runner/