Notes on migrating from CircleCI 1.0 to 2.0

Get an overview on this page http://tech.smarthr.jp/entry/2017/07/12/073000

Official documentation of the migration procedure https://circleci.com/docs/2.0/migrating-from-1-2/

Documentation that uses config-translation Endpoint https://circleci.com/docs/2.0/config-translation/

Use config-translation Endpoint to get the configuration file.

Suppose the build page on CircleCI is the following URL:

https://circleci.com/gh/:username/:project

In the above case, the config-translation Endpoint would be a URL like this: Here, the branch is specified as develop.

https://circleci.com/api/v1.1/project/github/:username/:project/config-translation?branch=develop

The file is downloaded with the file name config-translation.

NG pattern I set the user name of my GitHub account to : username, and the following response result was obtained.

{
  "message" : "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}"
}

Incorporate the downloaded configuration file into the project.

Refer to the following https://circleci.com/docs/2.0/migrating-from-1-2/

Create a .circleci folder in the project root, move the downloaded configuration file to it, and rename the file to config.yml.

$ mkdir .circleci
$ mv /hoge/config-translation .circleci/config.yml

Add the description about Deployment.

There is no description of Deployment in the downloaded configuration file, so you need to write it yourself.

An error occurs in maven integration-test.

#!/bin/bash --login
mvn integration-test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.104 s
[INFO] Finished at: 2018-04-09T04:25:24+00:00
[INFO] Final Memory: 15M/904M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/ubuntu/topgate/hogehoge/server). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
Exited with code 1

It is said that pom.xml does not exist. pom.xml exists in /server/pom.xml. In 1.0, the following description was OK.

general:
  build_dir: server

In 2.0, it is converted as follows, but since it checks out to working_directory, it is changed to ~ / topgate / hogehoge / server / server instead of ~ / topgate / hogehoge / server. , pom.xml existed, and without pom.xml, an error occurred.

version: 2
jobs:
  build:
    working_directory: ~/topgate/hogehoge/server

I can think of the following two solutions. Proposal (1) Set working_directory: ~ / topgate / hogehoge / server / server as an option when executing the mvn command.

    - run:
        working_directory: ~/topgate/hogehoge/server/server
        command: mvn dependency:go-offline || true

Proposal (2) Set path: ~ / topgate / hogehoge in the checkout command and specify the next higher level folder.

    - checkout:
        path: ~/topgate/hogehoge

I got stuck in config.yml

Workflows didn't work and I didn't notice the difference in the following description and got stuck.

NG pattern (filters is in the same position as build.)

    jobs:
      - build:
        filters:
          tags:
            only: /.*/

OK pattern (filters is the child position of build.)

    jobs:
      - build:
          filters:
            tags:
              only: /.*/

Job doesn't respond with git tag

In 1.0, in order to deploy with git tag, the following description was made.

deployment:
  prod:
    tag: /release-.*/
#・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ Omitted ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・
  dev:
    branch: develop

In 2.0, the job does not start with git tag, but the job starts using workflows.

Git Tag Job Execution https://circleci.com/docs/2.0/workflows/#git-tag-job-execution

Jobs with 2.0 respond to branch changes by default, but not to tagging. So, you need to create a filter for tag using filters so that the job starts with tagging.

Actually, it was described as follows.

version: 2
jobs:
  build:
    #・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ Omitted ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・
    - deploy:
        name: deploy to prod
        command: |
            if [[ "${CIRCLE_TAG}" =~ ^release-.* ]]; then
                #・ ・ ・ ・ ・ ・ ・ ・ ・ Deploy command (omitted) ・ ・ ・ ・ ・ ・ ・ ・
            fi
    - deploy:
        name: deploy to dev
        command: |
            if [ "${CIRCLE_BRANCH}" == "develop" ]; then
                #・ ・ ・ ・ ・ ・ ・ ・ ・ Deploy command (omitted) ・ ・ ・ ・ ・ ・ ・ ・
            fi
#・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ Omitted ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・
workflows:
  version: 2
  build-deploy:
    jobs:
      - build:
          filters:
            tags:
              only: /.*/

Recommended Posts

Notes on migrating from CircleCI 1.0 to 2.0
Notes on character encoding when migrating from windows to Mac
Notes on building Kotlin development environment and migrating from Java to Kotlin
Migrating from vargrant to docker
Upgrade from MYSQL5.7 to 8.0 on CentOS 6.7
Language summary to learn from now on
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
Precautions when migrating from VB6.0 to JAVA
Notes on getting Callback from Android text-to-speech function TextToSpeech
Settings to bypass Docker Hub restrictions on CircleCI
Migration from Eclipse to IntelliJ (on the way)
Notes on how to use each JUnit Rule
Migrating from Eclipse server function (Tomcat) to Embed Tomcat
Notes on how to create Burp Suite extensions
Notes on how to write comments in English
Notes on Protocol Buffers
Changes from Java 8 to Java 11
Sum from Java_1 to 100
Migrate from JUnit 4 to JUnit 5
Introducing CircleCI to Rails
Run Rubocop and RSpec on CircleCI and deploy to ECS
python notes on docker
[Android] Notes on xml
List how to learn from Docker to AKS on AWS
The story of migrating from Paperclip to Active Storage
To connect from Spring to MySQL on virtual server (unsolved)
[Updated from time to time] Ruby on Rails Convenient methods
Notes on multiple inheritance
Notes on regular expressions
How to connect to ClearDB from Sequel Pro on Heroku
Measures to prevent MySQL/MariaDB process from crashing on CentOS7
From Java to Ruby !!
Notes on updating Ubuntu from the command line (16.04 → 18.04, 18.04 → 20.04 both)
[Ruby on Rails] From MySQL construction to database change
Notes on how to use regular expressions in Java
From Unity ML-Agents release_6 Install to environmental testing on Win10.
From 0 to Ruby on Rails environment construction [macOS] (From Homebrew installation to Rails installation)
[Note] Flow from docker installation to JupyterLab startup on ubuntu
Catch up on new features from Java 7 to Java 9 at once
From Ruby on Rails error message display to Japanese localization
How to disable Set-Cookie from API on the front side
ClassCastException occurs when migrating from Java7 to Java8 ~ Generics and overload ~
[Opens aml] NoClassDefFoundError occurs when migrating from Tomcat to weblogic
Moved from iBATIS to MyBatis3
Try Spring Boot from 0 to 100.
Migration from Cobol to JAVA
Switch from slim3-gen to slim3-gen-jsr269
Moving from AWS to PaizaCloud
New features from Java7 to Java8
How to deploy on heroku
Connect from Java to PostgreSQL
Convert from ○ months to ○ years ○ months
Put Oracle Java 8 on CircleCI 2
Rewriting from applet to application
[Ruby] Notes on gets method
Change from SQLite3 to PostgreSQL
From Ineffective Java to Effective Java
How to migrate from JUnit4 to JUnit5
Steps to install samba on CentOS 8 and connect from Windows 10 Explorer
From building to deploying Ruby on Jets in docker-compose environment <Part 2>