이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 4. Configuring RHTAP to use built-in Jenkins libraries


By default {ProductLongName} (RHTAP) uses dynamically loaded Jenkins libraries. While dynamically loading provides flexibility, using built-in Jenkins libraries offer improved stability, security, and traceability during builds. Configuring RHTAP to use built-in libraries instead of dynamically loaded ones allows for better Red Hat Enterprise Contract (Enterprise Contract) attestations and enhanced build verification.

Prerequisites

Before making changes, ensure that:

4.1. Define the built-in library in Jenkins

Procedure

  1. Log in to Jenkins and navigate to Manage Jenkins > System.
  2. Locate the Global Trusted Pipeline Libraries section.
  3. Click Add and define the new library with the following parameters:

    1. Name: <your-library-name>
    2. Default version: Set to a specific branch or commit reference. For example, v1.4.
    3. Allow default version to be overridden: (Optional) Select this option to restrict users to a specific version of the Jenkins library. This ensures that the users cannot select a different version.
    4. Include @Library changes in your recent changes: Select this option to track modifications made to the shared library. This feature helps users understand changes that might affect their builds.
    5. Retrieval method: Select Modern SCM.

      1. From the Source Code Management drop-down list, select Git.
      2. In the Project Repository field, enter the Jenkins library URL. For example, https://github.com/redhat-appstudio/tssc-sample-jenkins.
      3. Select Fresh clone per build, to ensure each build fetches a clean copy of the library.
      4. Select Save.

4.2. Modify the Jenkins pipeline to use the built-in library

Procedure

  1. Navigate to your Jenkins CI source repository, For example, https://github.com/redhat-appstudio/tssc-sample-templates/blob/main/skeleton/ci/source-repo/jenkins.
  2. Select Jenkinsfile in edit mode.
  3. Replace the dynamic library loading with the @Library annotation.

    Replace thisWith this

    library identifier: 'RHTAP_Jenkins@main', retriever: modernSCM( [$class: 'GitSCMSource', remote: 'https://github.com/redhat-appstudio/tssc-sample-jenkins.git'])

    @Library('RHTAP_Jenkins@v1.4') _

  4. Save and commit the updated Jenkinsfile.

4.3. Use the configured Jenkins library

Procedure

  1. In your Jenkins instance, navigate to your project.
  2. Select Build Now to trigger a new build.

Verification

  1. Check the Jenkins build logs to confirm that the built-in library is loaded instead of dynamically retrieving dependencies.
  2. Validate that Enterprise Contract attestations now reflect a built-in library.
  3. Verify the library name, retrieval method, and pipeline script if any error occur.

4.4. Applying changes to one or all RHTAP templates

Depending on your use case, you can apply this configuration to one RHTAP template or all RHTAP templates in Red Hat Developer Hub (RHDH).

  • To apply this change to a single template: Modify only the specific pipeline template used in your project. This ensures that only this pipeline uses the built-in Jenkins library, while others continue using dynamic loading.
  • To apply this change to all RHTAP templates in RHDH: Update the global RHTAP template configuration to reference the built-in library instead of dynamically loaded ones. This ensures consistency across all RHTAP pipelines.
Important

Applying this change globally may impact all builds using RHTAP. Ensure that the built-in library is correctly defined and tested before making this change across all templates.

Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.