Skip to content

Latest commit

 

History

History
1062 lines (998 loc) · 27.4 KB

semver-resource.md

File metadata and controls

1062 lines (998 loc) · 27.4 KB

semverリソースでのバージョンの管理

hello-servletプロジェクトのforkおよびhello-servlet-versionプロジェクトの作成

image

image

image

image

image

image

ssh-keygen -t rsa -f ~/.ssh/github
# Passphraseは空でOK
chmod 400 ~/.ssh/github

~/.ssh/config

host github.com
 HostName github.com
 IdentityFile ~/.ssh/github
 User git

image

image

~/.ssh/github.pub

image

image

image

リリースバージョンの設定

---
resources:
- name: repo
  type: git
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet.git
    private_key: ((github-private-key))
    branch: master
- name: repo-version
  type: semver
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet-version.git
    branch: master
    private_key: ((github-private-key))
    file: version
    driver: git
- name: cf
  type: cf
  source:
    api: ((cf-api))
    username: ((cf-username))
    password: ((cf-password))
    organization: ((cf-org))
    space: ((cf-space))
    skip_cert_check: true
jobs:
- name: unit-test
  plan:
  - get: repo
    trigger: true
  - task: mvn-test
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn test
- name: upload-to-nexus-snapshots
  plan:
  - get: repo
    passed:
    - unit-test
    trigger: true
  - task: mvn-deploy
    params: &NEXUS_SNAPSHOT
      NEXUS_URL: ((nexus-snapshot-url))
      NEXUS_USERNAME: ((nexus-username))
      NEXUS_PASSWORD: ((nexus-password))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      caches:
      - path: repo/m2
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          cat > settings.xml <<EOF
          <settings>
            <servers>
              <server>
                 <id>repo</id>
                 <username>${NEXUS_USERNAME}</username>
                 <password>${NEXUS_PASSWORD}</password>
              </server>
            </servers>
          </settings>
          EOF
          mvn deploy -s settings.xml -DskipTests=true -DaltDeploymentRepository=repo::default::${NEXUS_URL} -Dmaven.wagon.http.ssl.insecure=true -D maven.wagon.http.ssl.ignore.validity.dates=true
- name: deploy
  plan:
  - get: repo
    passed:
    - upload-to-nexus-snapshots
    trigger: true
  - task: download-artifact
    params:
      <<: *NEXUS_SNAPSHOT
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          GROUP_ID=`grep '<groupId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?groupId>||g'`
          ARTIFACT_ID=`grep '<artifactId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?artifactId>||g'`
          VERSION=`grep '<version>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?version>||g'`
          URL=${NEXUS_URL}/`echo ${GROUP_ID} | sed 's|\.|/|g'`/${ARTIFACT_ID}/${VERSION}
          SNAPSHOT=`curl -k -s ${URL}/maven-metadata.xml | grep '<snapshotVersions>' -A 3 | grep 'value' | tr -d ' ' | tr -d '</value>'`
          echo "Download ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war"
          curl -k -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} -L -J -O ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war
          mv *.war ../build/ROOT.war
  - put: cf
    params:
      manifest: repo/manifest.yml
      path: build/ROOT.war
      current_app_name: hello-servlet
- name: tag-master
  plan:
  - aggregate:
    - get: repo
      passed:
      - deploy
    - get: repo-version
  - task: mvn-versions-set
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      - name: repo-version
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          VERSION=`cat repo-version/number`
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn versions:set -DnewVersion=${VERSION}

注意 アプリケーションのURLが重複しないように、current_app_name: hello-servlethello-servlethello-servlet-自分のアカウント名に変更してください。

credentials.yml

---
cf-api: https://api.run.pivotal.io
cf-username: xxxxxx
cf-password: xxxxxx
cf-org: xxxxxx
cf-space: xxxxxx
nexus-snapshot-url: https://192.168.230.40/repository/maven-snapshots/
nexus-username: admin
nexus-password: admin123
github-private-key: |
  -----BEGIN RSA PRIVATE KEY-----
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  -----END RSA PRIVATE KEY-----
fly -t ws set-pipeline -p hello-servlet -c pipeline.yml -l credentials.yml

image

image

fly -t ws trigger-job -j hello-servlet/tag-master --watch

image

リリースとGitの更新

---
resources:
- name: repo
  type: git
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet.git
    private_key: ((github-private-key))
    branch: master
- name: repo-version
  type: semver
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet-version.git
    branch: master
    private_key: ((github-private-key))
    file: version
    driver: git
- name: cf
  type: cf
  source:
    api: ((cf-api))
    username: ((cf-username))
    password: ((cf-password))
    organization: ((cf-org))
    space: ((cf-space))
    skip_cert_check: true
jobs:
- name: unit-test
  plan:
  - get: repo
    trigger: true
  - task: mvn-test
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn test
- name: upload-to-nexus-snapshots
  plan:
  - get: repo
    passed:
    - unit-test
    trigger: true
  - task: mvn-deploy
    params: &NEXUS_SNAPSHOT
      NEXUS_URL: ((nexus-snapshot-url))
      NEXUS_USERNAME: ((nexus-username))
      NEXUS_PASSWORD: ((nexus-password))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      caches:
      - path: repo/m2
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          cat > settings.xml <<EOF
          <settings>
            <servers>
              <server>
                 <id>repo</id>
                 <username>${NEXUS_USERNAME}</username>
                 <password>${NEXUS_PASSWORD}</password>
              </server>
            </servers>
          </settings>
          EOF
          mvn deploy -s settings.xml -DskipTests=true -DaltDeploymentRepository=repo::default::${NEXUS_URL} -Dmaven.wagon.http.ssl.insecure=true -D maven.wagon.http.ssl.ignore.validity.dates=true
- name: deploy
  plan:
  - get: repo
    passed:
    - upload-to-nexus-snapshots
    trigger: true
  - task: download-artifact
    params:
      <<: *NEXUS_SNAPSHOT
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          GROUP_ID=`grep '<groupId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?groupId>||g'`
          ARTIFACT_ID=`grep '<artifactId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?artifactId>||g'`
          VERSION=`grep '<version>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?version>||g'`
          URL=${NEXUS_URL}/`echo ${GROUP_ID} | sed 's|\.|/|g'`/${ARTIFACT_ID}/${VERSION}
          SNAPSHOT=`curl -k -s ${URL}/maven-metadata.xml | grep '<snapshotVersions>' -A 3 | grep 'value' | tr -d ' ' | tr -d '</value>'`
          echo "Download ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war"
          curl -k -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} -L -J -O ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war
          mv *.war ../build/ROOT.war
  - put: cf
    params:
      manifest: repo/manifest.yml
      path: build/ROOT.war
      current_app_name: hello-servlet
- name: tag-master
  plan:
  - aggregate:
    - get: repo
      passed:
      - deploy
    - get: repo-version
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      - name: repo-version
      outputs:
      - name: output
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          VERSION=`cat repo-version/number`
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn versions:set -DnewVersion=${VERSION}
          rm -f pom.xml.versionsBackup
          shopt -s dotglob
          shopt -s extglob
          mv -f !(m2) ../output/
          cd ../output
          git config --global user.email "${GIT_EMAIL}"
          git config --global user.name "${GIT_NAME}"
          git add -A
          git commit -m "Release ${VERSION}"
  - put: repo
    params:
      repository: output
      tag: repo-version/number

注意 アプリケーションのURLが重複しないように、current_app_name: hello-servlethello-servlethello-servlet-自分のアカウント名に変更してください。

credentials.yml

---
cf-api: https://api.run.pivotal.io
cf-username: xxxxxx
cf-password: xxxxxx
cf-org: xxxxxx
cf-space: xxxxxx
nexus-snapshot-url: https://192.168.230.40/repository/maven-snapshots/
nexus-username: admin
nexus-password: admin123
git-email: [email protected]
git-name: Your Name
github-private-key: |
  -----BEGIN RSA PRIVATE KEY-----
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  -----END RSA PRIVATE KEY-----

image

Nexusへのアップデートおよび、次の開発バージョン(パッチバージョン)へのアップデート

---
resources:
- name: repo
  type: git
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet.git
    private_key: ((github-private-key))
    branch: master
- name: repo-version
  type: semver
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet-version.git
    branch: master
    private_key: ((github-private-key))
    file: version
    driver: git
- name: cf
  type: cf
  source:
    api: ((cf-api))
    username: ((cf-username))
    password: ((cf-password))
    organization: ((cf-org))
    space: ((cf-space))
    skip_cert_check: true
jobs:
- name: unit-test
  plan:
  - get: repo
    trigger: true
  - task: mvn-test
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn test
- name: upload-to-nexus-snapshots
  plan:
  - get: repo
    passed:
    - unit-test
    trigger: true
  - task: mvn-deploy
    params: &NEXUS_SNAPSHOT
      NEXUS_URL: ((nexus-snapshot-url))
      NEXUS_USERNAME: ((nexus-username))
      NEXUS_PASSWORD: ((nexus-password))
    config: &NEXUS_DEPLOY_CONFIG
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      caches:
      - path: repo/m2
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          cat > settings.xml <<EOF
          <settings>
            <servers>
              <server>
                 <id>repo</id>
                 <username>${NEXUS_USERNAME}</username>
                 <password>${NEXUS_PASSWORD}</password>
              </server>
            </servers>
          </settings>
          EOF
          mvn deploy -s settings.xml -DskipTests=true -DaltDeploymentRepository=repo::default::${NEXUS_URL} -Dmaven.wagon.http.ssl.insecure=true -D maven.wagon.http.ssl.ignore.validity.dates=true
- name: deploy
  plan:
  - get: repo
    passed:
    - upload-to-nexus-snapshots
    trigger: true
  - task: download-artifact
    params:
      <<: *NEXUS_SNAPSHOT
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          GROUP_ID=`grep '<groupId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?groupId>||g'`
          ARTIFACT_ID=`grep '<artifactId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?artifactId>||g'`
          VERSION=`grep '<version>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?version>||g'`
          URL=${NEXUS_URL}/`echo ${GROUP_ID} | sed 's|\.|/|g'`/${ARTIFACT_ID}/${VERSION}
          SNAPSHOT=`curl -k -s ${URL}/maven-metadata.xml | grep '<snapshotVersions>' -A 3 | grep 'value' | tr -d ' ' | tr -d '</value>'`
          echo "Download ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war"
          curl -k -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} -L -J -O ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war
          mv *.war ../build/ROOT.war
  - put: cf
    params:
      manifest: repo/manifest.yml
      path: build/ROOT.war
      current_app_name: hello-servlet
- name: tag-master
  plan:
  - aggregate:
    - get: repo
      passed:
      - deploy
    - get: repo-version
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      - name: repo-version
      outputs:
      - name: output
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          VERSION=`cat repo-version/number`
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn versions:set -DnewVersion=${VERSION}
          rm -f pom.xml.versionsBackup
          shopt -s dotglob
          shopt -s extglob
          mv -f !(m2) ../output/
          cd ../output
          git config --global user.email "${GIT_EMAIL}"
          git config --global user.name "${GIT_NAME}"
          git add -A
          git commit -m "Release ${VERSION}"
  - put: repo
    params:
      repository: output
      tag: repo-version/number
- name: upload-to-nexus-releases
  plan:
  - get: repo
    passed:
    - tag-master
    trigger: true
  - task: mvn-deploy
    params: &NEXUS_RELEASE
      NEXUS_URL: ((nexus-release-url))
      NEXUS_USERNAME: ((nexus-username))
      NEXUS_PASSWORD: ((nexus-password))
    config:
      <<: *NEXUS_DEPLOY_CONFIG
- name: bump-to-next-patch-version
  plan:
  - aggregate:
    - get: repo
      passed:
      - upload-to-nexus-releases
      trigger: true
    - get: repo-version
      params:
        bump: patch
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      - name: repo-version
      outputs:
      - name: output
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          VERSION=`cat repo-version/number`-SNAPSHOT
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn versions:set -DnewVersion=${VERSION} -DallowSnapshots
          rm -f pom.xml.versionsBackup
          shopt -s dotglob
          shopt -s extglob
          mv -f !(m2) ../output/
          cd ../output
          git config --global user.email "${GIT_EMAIL}"
          git config --global user.name "${GIT_NAME}"
          git add -A
          git commit -m "Bump to ${VERSION}"
  - put: repo
    params:
      repository: output
  - put: repo-version
    params:
      file: repo-version/number

注意 アプリケーションのURLが重複しないように、current_app_name: hello-servlethello-servlethello-servlet-自分のアカウント名に変更してください。

credentials.yml

---
cf-api: https://api.run.pivotal.io
cf-username: xxxxxx
cf-password: xxxxxx
cf-org: xxxxxx
cf-space: xxxxxx
nexus-snapshot-url: https://192.168.230.40/repository/maven-snapshots
nexus-release-url: https://192.168.230.40/repository/maven-releases
nexus-username: admin
nexus-password: admin123
git-email: [email protected]
git-name: Your Name
github-private-key: |
  -----BEGIN RSA PRIVATE KEY-----
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  -----END RSA PRIVATE KEY-----

image

image image

image

image

マイナーバージョン、メジャーバージョンへの手動アップデート

---
resources:
- name: repo
  type: git
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet.git
    private_key: ((github-private-key))
    branch: master
- name: repo-version
  type: semver
  source:
    uri: [email protected]:pivot-tmaki/hello-servlet-version.git
    branch: master
    private_key: ((github-private-key))
    file: version
    driver: git
- name: cf
  type: cf
  source:
    api: ((cf-api))
    username: ((cf-username))
    password: ((cf-password))
    organization: ((cf-org))
    space: ((cf-space))
    skip_cert_check: true
jobs:
- name: unit-test
  plan:
  - get: repo
    trigger: true
  - task: mvn-test
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn test
- name: upload-to-nexus-snapshots
  plan:
  - get: repo
    passed:
    - unit-test
    trigger: true
  - task: mvn-deploy
    params: &NEXUS_SNAPSHOT
      NEXUS_URL: ((nexus-snapshot-url))
      NEXUS_USERNAME: ((nexus-username))
      NEXUS_PASSWORD: ((nexus-password))
    config: &NEXUS_DEPLOY_CONFIG
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      caches:
      - path: repo/m2
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          cat > settings.xml <<EOF
          <settings>
            <servers>
              <server>
                 <id>repo</id>
                 <username>${NEXUS_USERNAME}</username>
                 <password>${NEXUS_PASSWORD}</password>
              </server>
            </servers>
          </settings>
          EOF
          mvn deploy -s settings.xml -DskipTests=true -DaltDeploymentRepository=repo::default::${NEXUS_URL} -Dmaven.wagon.http.ssl.insecure=true -D maven.wagon.http.ssl.ignore.validity.dates=true
- name: deploy
  plan:
  - get: repo
    passed:
    - upload-to-nexus-snapshots
    trigger: true
  - task: download-artifact
    params:
      <<: *NEXUS_SNAPSHOT
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      outputs:
      - name: build
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          cd repo
          GROUP_ID=`grep '<groupId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?groupId>||g'`
          ARTIFACT_ID=`grep '<artifactId>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?artifactId>||g'`
          VERSION=`grep '<version>' pom.xml | head -1  | sed -r 's/[ \f\n\r\t]+//g' | sed  -r 's|<.?version>||g'`
          URL=${NEXUS_URL}/`echo ${GROUP_ID} | sed 's|\.|/|g'`/${ARTIFACT_ID}/${VERSION}
          SNAPSHOT=`curl -k -s ${URL}/maven-metadata.xml | grep '<snapshotVersions>' -A 3 | grep 'value' | tr -d ' ' | tr -d '</value>'`
          echo "Download ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war"
          curl -k -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} -L -J -O ${URL}/${ARTIFACT_ID}-${SNAPSHOT}.war
          mv *.war ../build/ROOT.war
  - put: cf
    params:
      manifest: repo/manifest.yml
      path: build/ROOT.war
      current_app_name: hello-servlet
- name: tag-master
  plan:
  - aggregate:
    - get: repo
      passed:
      - deploy
    - get: repo-version
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      - name: repo-version
      outputs:
      - name: output
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          VERSION=`cat repo-version/number`
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn versions:set -DnewVersion=${VERSION}
          rm -f pom.xml.versionsBackup
          shopt -s dotglob
          shopt -s extglob
          mv -f !(m2) ../output/
          cd ../output
          git config --global user.email "${GIT_EMAIL}"
          git config --global user.name "${GIT_NAME}"
          git add -A
          git commit -m "Release ${VERSION}"
  - put: repo
    params:
      repository: output
      tag: repo-version/number
- name: upload-to-nexus-releases
  plan:
  - get: repo
    passed:
    - tag-master
    trigger: true
  - task: mvn-deploy
    params: &NEXUS_RELEASE
      NEXUS_URL: ((nexus-release-url))
      NEXUS_USERNAME: ((nexus-username))
      NEXUS_PASSWORD: ((nexus-password))
    config:
      <<: *NEXUS_DEPLOY_CONFIG
- name: bump-to-next-patch-version
  plan:
  - aggregate:
    - get: repo
      passed:
      - upload-to-nexus-releases
      trigger: true
    - get: repo-version
      params:
        bump: patch
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config: &MVN_VERSIONS_SET_CONFIG
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: maven
      inputs:
      - name: repo
      - name: repo-version
      outputs:
      - name: output
      caches:
      - path: repo/m2   
      run:
        path: bash
        args:
        - -c
        - |
          set -e
          VERSION=`cat repo-version/number`-SNAPSHOT
          cd repo
          rm -rf ~/.m2
          ln -fs $(pwd)/m2 ~/.m2
          mvn versions:set -DnewVersion=${VERSION} -DallowSnapshots
          rm -f pom.xml.versionsBackup
          shopt -s dotglob
          shopt -s extglob
          mv -f !(m2) ../output/
          cd ../output
          git config --global user.email "${GIT_EMAIL}"
          git config --global user.name "${GIT_NAME}"
          git add -A
          git commit -m "Bump to ${VERSION}"
  - put: repo
    params:
      repository: output
  - put: repo-version
    params:
      file: repo-version/number
- name: bump-to-next-minor-version
  plan:
  - aggregate:
    - get: repo
    - get: repo-version
      params:
        bump: minor
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config:
      <<: *MVN_VERSIONS_SET_CONFIG
  - put: repo
    params:
      repository: output
  - put: repo-version
    params:
      file: repo-version/number
- name: bump-to-next-major-version
  plan:
  - aggregate:
    - get: repo
    - get: repo-version
      params:
        bump: major
  - task: mvn-versions-set
    params:
      GIT_EMAIL: ((git-email))
      GIT_NAME: ((git-name))
    config:
      <<: *MVN_VERSIONS_SET_CONFIG
  - put: repo
    params:
      repository: output
  - put: repo-version
    params:
      file: repo-version/number

注意 アプリケーションのURLが重複しないように、current_app_name: hello-servlethello-servlethello-servlet-自分のアカウント名に変更してください。

image