티스토리 뷰
오늘은 간단하게 젠킨스에서 사용하는 글로벌 환경 변수 내용을 적용해보는 방법에 대해 살펴보고자 합니다.
1. Global Properties 설정
젠킨스 관리 -> 시스템 관리 -> 전역 변수로 이동해서 환경 변수를 설정합니다.
2. Jenkinsfile 설정
Docker를 사용할 때 Dockerfile 을 만들듯이 Jenkinsfile을 만들어 사용합니다. 보다 자세한 내용은 아래 나와있습니다.
Jenkinsfile (Declarative Pipeline)
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}
https://www.jenkins.io/doc/book/pipeline/jenkinsfile/
Using a Jenkinsfile
For more advanced usage with Scripted Pipeline, the example above node is a crucial first step as it allocates an executor and workspace for the Pipeline. In essence, without node, a Pipeline cannot do any work! From within node, the first order of busines
www.jenkins.io
3. EnvInject 사용하기
제가 환경 변수로 사용하는 방법 중에 1개인 EnvInject 입니다. 먼저 Jenkins Plugin Manager에서 플러그인을 설치한 후에 사용가능한데 가장 간편한 방법인 듯 합니다.
가장 먼저 매개변수를 설정합니다.
그리고 Build Steps 안에 Inject environment variables 로 환경변수를 추가하는 기능을 추가합니다.
아래는 공식 사이트가 나와 있습니다.
https://plugins.jenkins.io/envinject/
Environment Injector
This plugin makes it possible to set an environment for the builds.
plugins.jenkins.io
위에서 언급한 3가지 방법을 적용하기 위한 사이트로 아래를 참조하였습니다.
https://www.baeldung.com/ops/jenkins-environment-variables
How to Set Environment Variables in Jenkins? | Baeldung
Learn about the different ways to set and use environment variables in Jenkins.
www.baeldung.com
'Server' 카테고리의 다른 글
[JPA] Repository 내에서 Join 사용하기 (2) | 2022.12.07 |
---|---|
Spring Boot 3 버전으로 업그레이드 (0) | 2022.11.13 |
좋은 에러 메시지를 만드는 6가지 원칙 (6) | 2022.10.24 |
Amazon Linux 에서 자바 버전 변경하기 (0) | 2022.10.08 |
build.gradle 에서 application.properties 값 사용하는 방법 (0) | 2022.10.07 |
유료로 대체되는 Docker Desktop 대체하기 (0) | 2022.10.06 |