μ΅œκ·Όμ—λŠ” κΉƒν—ˆλΈŒ μ•‘μ…˜μ˜ μ›Œν¬ν”Œλ‘œμš° ν™œμš©ν•˜λŠ” κ²½μš°κ°€ 늘고 μžˆλŠ” 것 κ°™μ§€λ§Œ λŒ€λΆ€λΆ„μ˜ νšŒμ‚¬μ—μ„œλŠ” CI/CD λ„κ΅¬λ‘œ μ  ν‚¨μŠ€λ₯Ό 많이 μ‚¬μš©ν•  것이닀. 그런데 λŒ€λΆ€λΆ„ μ–΄λ–€ κ°œλ°œμžμ— μ˜ν•΄μ„œ μ  ν‚¨μŠ€κ°€ 이미 κ΅¬μ„±λ˜μ–΄μžˆκΈ° λ•Œλ¬Έμ— μ‹ μž… λ˜λŠ” μ£Όλ‹ˆμ–΄ κ°œλ°œμžκ°€ 직접 κ²½ν—˜ν•˜λŠ” 뢀뢄이 없을 수 μžˆλ‹€. λ¦¬λˆ…μŠ€ μ„œλ²„μ— JDKλ₯Ό μ„€μΉ˜ν•˜κ³  μ  ν‚¨μŠ€λ₯Ό μ‹€ν–‰ν•˜λ”λΌλ„ μš΄μ˜λ˜λŠ” ν™˜κ²½μ— 따라 μ‚¬μš©λ˜λŠ” JDKλ₯Ό μ‚¬μš©ν•˜μ—¬ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λΉŒλ“œν•˜λ„λ‘ κ΅¬μ„±ν•΄μ•Όν•œλ‹€.

JDK Installations

Jenkins 관리 > Global Tool Configuration > JDK installations μ—μ„œ μ  ν‚¨μŠ€ μ‹œμŠ€ν…œμ—μ„œ μ‚¬μš©λ  JDK λͺ©λ‘μ„ 관리할 수 μžˆλ„λ‘ μ œκ³΅ν•˜κ³  μžˆλ‹€. 이λ₯Ό ν™œμš©ν•΄μ„œ 각 ν”„λ‘œμ νŠΈμ—μ„œ μ‚¬μš©λ  JDK을 μ„€μΉ˜ν•΄μ„œ 운영 ν™˜κ²½μ—μ„œ μ‚¬μš©λ  JVM 버전과 λ™μΌν•œ JDK 벀더λ₯Ό μ‚¬μš©ν•΄μ„œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λΉŒλ“œν•  수 μžˆλ‹€.

일반적으둜 λ²”μš©μ μΈ λͺ©μ μœΌλ‘œλŠ” Temurinμ΄λΌλŠ” OpenJDKλ₯Ό μ‚¬μš©ν•˜κ³  νšŒμ‚¬μ—μ„œλŠ” 운영 ν™˜κ²½μΈ CSP와 λ™μΌν•œ Amazon Corretto JDKλ₯Ό μ‚¬μš©ν•˜κ³  μžˆλ‹€. κΈ°λ³Έμ μœΌλ‘œλŠ” μ  ν‚¨μŠ€κ°€ μ„€μΉ˜λœ μ„œλ²„ μ‹œμŠ€ν…œμ— μ—¬λŸ¬κ°œμ˜ JDKλ₯Ό μ„€μΉ˜ν•΄μ„œ μ‚¬μš©ν•˜λŠ” κ²ƒμœΌλ‘œ μ„€λͺ…ν•œλ‹€. λ‹€ν–‰νžˆλ„ JDK Tool Plugin μ—μ„œλŠ” λ‹€μš΄λ‘œλ“œ 링크λ₯Ό μ§€μ •ν•΄μ„œ μΆ”κ°€ν•  수 μžˆλŠ” Extract .zip/.tar.gz을 μ œκ³΅ν•˜κ³  μžˆλ‹€.

Downloads a tool archive and installs it within Jenkins’s working directory.
Example: https://downloads.apache.org/ant/binaries/apache-ant-1.10.12-bin.zip and specify a subdir of apache-ant-1.10.12 .

μœ„ μ„€λͺ…에 λ”°λΌμ„œ λ‹€μš΄λ‘œλ“œ 링크에 μ˜ν•΄μ„œ 압좕이 ν•΄μ œλ  폴더λ₯Ό μ§€μ •ν•΄μ•Όν•œλ‹€.

ν”„λ‘œμ νŠΈμ—μ„œ Amazon Corretto JDK μ‚¬μš©ν•˜κΈ°

ν”„λ‘œμ νŠΈ λΉŒλ“œ μœ ν˜•μ— λ”°λΌμ„œ μ„€μΉ˜ν•œ JDKλ₯Ό μ§€μ •ν•˜λŠ” 방법을 κ³΅μœ ν•˜κ³ μž ν•œλ‹€. νšŒμ‚¬μ—μ„œλŠ” Freestyle Project둜 κ°„λ‹¨ν•˜κ²Œ μ‚¬μš©ν•˜κ³  μžˆλŠ”λ° μΈν„°λ„·μ—μ„œλŠ” νŒŒμ΄ν”„λΌμΈλ„ 많이 ν™œμš©ν•˜κ³  μžˆλŠ” 것 κ°™λ‹€.

Freestyle Project

Started by user mambo
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building in workspace /var/jenkins_home/workspace/Test
[Test] $ /bin/sh -xe /tmp/jenkins17925040181999271110.sh
+ which java
/var/jenkins_home/tools/hudson.model.JDK/Amazon_Corretto_11/amazon-corretto-11.0.17.8.1-linux-x64/bin/java
+ java --version
openjdk 11.0.17 2022-10-18 LTS
OpenJDK Runtime Environment Corretto-11.0.17.8.1 (build 11.0.17+8-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.17.8.1 (build 11.0.17+8-LTS, mixed mode)
Finished: SUCCESS

μœ„μ™€ 같이 Execute Shell μ»€λ§¨λ“œλ₯Ό μ‚¬μš©ν•΄μ„œ ν˜„μž¬ λΉŒλ“œ ν™˜κ²½μ— λŒ€ν•œ μžλ°” 버전을 ν™•μΈν•΄λ³΄λ‹ˆ μ •μƒμ μœΌλ‘œ JDK둜 μ§€μ •ν•œ Amazon Corretto 11을 μ‚¬μš©μ€‘μΈ κ²ƒμœΌλ‘œ 좜λ ₯λ˜μ—ˆλ‹€. 그리고 νŒŒμ΄ν”„λΌμΈ ν”„λ‘œμ νŠΈμ—μ„œλŠ” μ–΄λ–»κ²Œ μ§€μ •ν•˜λŠ”μ§€ κ²€μƒ‰ν•΄λ³΄λ‹ˆ μ•„λž˜μ™€ 같이 문법을 μž‘μ„±ν•œλ‹€κ³  ν•œλ‹€.

pipeline {
    agent any
    
    tools {
        jdk "Amazon Corretto 11"
    }
    
    environment {
        JAVA_HOME = "tool Amazon Corretto 11"
    }

    stages {
        stage('Java Version') {
            steps {
                sh 'java -version'
            }
        }
    }
}

ν”„λ‘ νŠΈμ—”λ“œ λΉŒλ“œμ— μ‚¬μš©λ  Node 버전을 μ„€μΉ˜ν•˜κΈ° μœ„ν•΄μ„œλŠ” NodeJS ν”ŒλŸ¬κ·ΈμΈμ„ μ„€μΉ˜ν•˜λ©΄ λ™μΌν•˜κ²Œ Global Tool Configuration κΈ°λŠ₯에 NodeJS installations ν•­λͺ©μ΄ μΆ”κ°€λ©λ‹ˆλ‹€.