このコンテンツは選択した言語では利用できません。

Appendix C. Configuring a Jenkins freestyle project to deploy your Node.js application with nodeshift


Similar to using nodeshift from your local host to deploy a Node.js application, you can configure Jenkins to use nodeshift to deploy a Node.js application.

Prerequisites

  • Access to an OpenShift cluster.
  • The Jenkins container image running on same OpenShift cluster.
  • The Node.js plugin installed on your Jenkins server.
  • A Node.js application configured to use nodeshift and the Red Hat base image.

    Example using the Red Hat base image with nodeshift

    $ nodeshift --dockerImage=registry.access.redhat.com/rhscl/ubi8/nodejs-12 ...

  • The source of the application available in GitHub.

Procedure

  1. Create a new OpenShift project for your application:

    1. Open the OpenShift Web console and log in.
    2. Click Create Project to create a new OpenShift project.
    3. Enter the project information and click Create.
  2. Ensure Jenkins has access to that project.

    For example, if you configured a service account for Jenkins, ensure that account has edit access to the project of your application.

  3. Create a new freestyle Jenkins project on your Jenkins server:

    1. Click New Item.
    2. Enter a name, choose Freestyle project, and click OK.
    3. Under Source Code Management, choose Git and add the GitHub url of your application.
    4. Under Build Environment, make sure Provide Node & npm bin/ folder to PATH is checked and the Node.js environment is configured.
    5. Under Build, choose Add build step and select Execute Shell.
    6. Add the following to the Command area:

      npm install -g nodeshift
      nodeshift --dockerImage=registry.access.redhat.com/rhscl/ubi8/nodejs-12 --namespace=MY_PROJECT

      Substitute MY_PROJECT with the name of the OpenShift project for your application.

    7. Click Save.
  4. Click Build Now from the main page of the Jenkins project to verify your application builds and deploys to the OpenShift project for your application.

    You can also verify that your application is deployed by opening the route in the OpenShift project of the application.

Next steps

  • Consider adding GITSCM polling or using the Poll SCM build trigger. These options enable builds to run every time a new commit is pushed to the GitHub repository.
  • Consider adding nodeshift as a global package when configuring the Node.js plugin. This allows you to omit npm install -g nodeshift when adding your Execute Shell build step.
  • Consider adding a build step that executes tests before deploying.
Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.