Cloud Manager 내에서 암호로 보호된 Maven 저장소 사용

노트
Cloud Manager에서 해당 코드 품질 규칙과 함께 이 코드를 평가하지 않으므로 암호로 보호된 Maven 저장소에서 아티팩트를 신중하게 배포하십시오. 이 메서드는 드문 경우에만 예약해야 하며 AEM과 관련이 없는 코드에만 적용되어야 합니다. Adobe은 이진과 함께 Java 소스 및 전체 프로젝트 소스 코드를 모두 포함하는 것을 권장합니다. 이렇게 하면 배포 프로세스 전반에 걸쳐 투명성과 유지 관리성이 향상됩니다.

Cloud Manager 내에서 암호로 보호된 Maven 저장소를 사용하려면:

  1. 암호(및 선택적으로 사용자 이름)를 비밀 파이프라인 변수로 지정합니다.
  2. 그런 다음 Maven 설정 파일 스키마를 따르는 git 저장소의 .cloudmanager/maven/settings.xml 파일 내에서 해당 비밀로 참조합니다.

Cloud Manager 빌드 프로세스가 시작되면 다음 작업을 수행하십시오.

  • 이 파일의 <servers> 요소는 Cloud Manager에서 제공하는 기본 settings.xml 파일에 병합됩니다.

    • adobecloud-manager(으)로 시작하는 서버 ID는 예약된 것으로 간주됩니다. 사용자 지정 서버에서는 사용하지 마십시오.
    • Cloud Manager은 특정 접두사 또는 기본 ID central과(와) 일치하는 서버 ID만 미러링합니다. 다른 모든 서버 ID는 미러링에서 제외됩니다.
  • 이 파일이 있는 경우 서버 ID는 pom.xml 파일 내의 <repository> 및/또는 <pluginRepository> 요소 내부에서 참조됩니다.

  • 일반적으로 이러한 <repository><pluginRepository> 요소는 Cloud Manager 관련 프로필 내에 포함되지만 반드시 포함시켜야 하는 것은 아닙니다.

예를 들어 저장소가 https://repository.myco.com/maven2에 있고 Cloud Manager가 사용해야 하는 사용자 이름은 cloudmanager, 암호가 secretword라고 가정해 보겠습니다. 다음 단계를 수행합니다.

  1. 파이프라인에서 암호를 비밀로 설정합니다.

    $ aio cloudmanager:set-pipeline-variables PIPELINEID --secret CUSTOM_MYCO_REPOSITORY_PASSWORD secretword`
    
  2. 다음 파일의 .cloudmanager/maven/settings.xml 파일에서 이 암호를 참조합니다.

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="https://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="https://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
        <servers>
            <server>
                <id>myco-repository</id>
                <username>cloudmanager</username>
               <password>${env.CUSTOM_MYCO_REPOSITORY_PASSWORD}</password>
            </server>
        </servers>
    </settings>
    
  3. 마지막으로 pom.xml 파일 내에서 서버 ID를 참조합니다.

    <profiles>
        <profile>
            <id>cmBuild</id>
            <activation>
                    <property>
                        <name>env.CM_BUILD</name>
                    </property>
            </activation>
            <repositories>
                 <repository>
                     <id>myco-repository</id>
                     <name>MyCo Releases</name>
                     <url>https://repository.myco.com/maven2</url>
                     <snapshots>
                         <enabled>false</enabled>
                     </snapshots>
                     <releases>
                         <enabled>true</enabled>
                     </releases>
                 </repository>
             </repositories>
             <pluginRepositories>
                 <pluginRepository>
                     <id>myco-repository</id>
                     <name>MyCo Releases</name>
                     <url>https://repository.myco.com/maven2</url>
                     <snapshots>
                         <enabled>false</enabled>
                     </snapshots>
                     <releases>
                         <enabled>true</enabled>
                     </releases>
                 </pluginRepository>
             </pluginRepositories>
        </profile>
    </profiles>
    

소스 배포

Maven 저장소에 이진과 함께 Java 소스를 배포하는 것이 좋습니다.

이렇게 하려면 프로젝트에서 maven-source-plugin을 구성합니다.

         <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-source-plugin</artifactId>
             <executions>
                 <execution>
                     <id>attach-sources</id>
                     <goals>
                         <goal>jar-no-fork</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>

프로젝트 소스 배포

Maven 저장소에 이진과 함께 전체 프로젝트 소스를 배포하는 것이 좋습니다. 이렇게 하면 정확한 아티팩트를 재구축할 수 있습니다.

다음 방식으로 프로젝트에서 maven-assembly-plugin을 구성합니다.

         <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-assembly-plugin</artifactId>
             <executions>
                 <execution>
                     <id>project-assembly</id>
                     <phase>package</phase>
                     <goals>
                         <goal>single</goal>
                     </goals>
                     <configuration>
                         <descriptorRefs>
                             <descriptorRef>project</descriptorRef>
                         </descriptorRefs>
                     </configuration>
                 </execution>
             </executions>
         </plugin>

콘텐츠 패키지 건너뛰기

Cloud Manager에서 빌드는 콘텐츠 패키지를 원하는 수만큼 생성할 수 있습니다. 여러 가지 이유로 콘텐츠 패키지를 생성하지만 배포하지 않는 것이 바람직할 수 있습니다. 콘텐츠 패키지가 테스트 목적으로만 빌드되거나 빌드 프로세스의 다른 단계에서 다시 패키징되는 경우 예제가 발생합니다. 즉, 다른 패키지의 하위 패키지입니다.

이러한 시나리오를 수용하기 위해 Cloud Manager는 빌드된 콘텐츠 패키지의 속성에서 cloudManagerTarget이라는 속성을 찾습니다. 이 속성을 none으로 설정하면 패키지를 건너뛰고 배포되지 않습니다.

이 속성을 설정하는 메커니즘은 빌드가 콘텐츠 패키지를 생성하는 방식에 따라 다릅니다. 예를 들어 filevault-maven-plugin을 사용하여 다음과 같이 플러그인을 구성합니다.

        <plugin>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>filevault-package-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <properties>
                    <cloudManagerTarget>none</cloudManagerTarget>
                </properties>
        <!-- other configuration -->
            </configuration>
        </plugin>

content-package-maven-plugin도 비슷한 구성을 가지고 있습니다.

        <plugin>
            <groupId>com.day.jcr.vault</groupId>
            <artifactId>content-package-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <properties>
                    <cloudManagerTarget>none</cloudManagerTarget>
                </properties>
        <!-- other configuration -->
            </configuration>
        </plugin>

빌드 아티팩트 재사용

많은 경우 동일한 코드가 여러 AEM 환경에 배포됩니다. 가능한 경우, Cloud Manager는 동일한 git 커밋이 여러 전체 스택 파이프라인 실행에 사용되는 것을 감지하면 코드 베이스를 다시 빌드하지 않습니다.

실행이 시작되면 분기 파이프라인에 대한 현재 HEAD 커밋이 추출됩니다. 커밋 해시는 UI와 API를 통해 볼 수 있습니다. 빌드 단계가 정상적으로 완료되면 결과 아티팩트가 해당 커밋 해시를 기반으로 저장되고 후속 파이프라인 실행에서 재사용될 수 있습니다.

동일한 프로그램에 있는 경우 파이프라인에서 패키지가 재사용됩니다. 재사용할 수 있는 패키지를 찾을 때 AEM은 분기를 무시하고 분기 간에 아티팩트를 재사용합니다.

재사용이 발생하면 빌드 및 코드 품질 단계가 원래 실행의 결과로 효과적으로 대체됩니다. 빌드 단계의 로그 파일에는 원래 빌드하는 데 사용된 아티팩트와 실행 정보가 나열됩니다.

다음은 이러한 로그 출력의 예입니다.

The following build artifacts were reused from the prior execution 4 of pipeline 1 which used commit f6ac5e6943ba8bce8804086241ba28bd94909aef:
build/aem-guides-wknd.all-2021.1216.1101633.0000884042.zip (content-package)
build/aem-guides-wknd.dispatcher.cloud-2021.1216.1101633.0000884042.zip (dispatcher-configuration)

코드 품질 단계의 로그에는 유사한 정보가 포함됩니다.