반응형
    
    
    
  .
Jenkins 에서 Lambda Plugin을 사용한 코드배포 및 함수 실행이다.
1. 람다 생성 및 기본적인 플러그인 세팅
1.1) jenkinsTest 람다 함수생성

1.2) Jenkins Lambda Plugin 세팅

2. 파이프라인 세팅
pipeline {
    agent any
    
    stages {
        stage('Git CheckOut'){
            steps{
                git branch: 'main', url: 'https://github.com/ / .git'
            }
        }
        stage('Make .zip'){
            steps{
                zip zipFile: 'test.zip'
            }
        }
        stage('lambda deploy'){
            steps{
                 withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'pangyeon',
                    accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]){
                    deployLambda(
                        awsRegion: 'ap-northeast-2',
                        awsAccessKeyId: "${AWS_ACCESS_KEY_ID}",
                        awsSecretKey: "${AWS_SECRET_ACCESS_KEY}",
                        functionName: 'jenkinsTest',
                        artifactLocation: 'test.zip',
                        updateMode: 'code'
                    )
                }
            }
        }
        stage('lambda invoke'){
            steps{
                withAWS(region:'ap-northeast-2', credentials:'pangyeon') {
                    invokeLambda(
                        functionName: 'jenkinsTest'
                    )
                }
            }
        }
    }
    post { 
        always { 
            sh 'rm test.zip'
        }
    }
}
3. 실행

4. 배포 확인
4.1) 이전 코드

4.2) 배포 후 코드

5. 실행 확인
5.1) Jenkins 실행 로그
RequestId : d019e541-92df-4fac-9021-96f150b793c2

5.2) Lambda 로그
RequestId : d019e541-92df-4fac-9021-96f150b793c2

5.1, 5.2의 RequestId가 동일하다는 것을 볼 수 있다.
반응형
    
    
    
  'Develop > 기타 작업' 카테고리의 다른 글
| Jenkins Git Checkout timeout (pipeline script) (0) | 2022.11.01 | 
|---|---|
| unable to find valid certification path to requested target (Windows Android Studio) (0) | 2022.07.30 | 
| Groovy REST API 호출(Groovy HttpBuilder) (0) | 2022.07.06 | 
| Invalid option '.socket.binding.port-offset=100' (0) | 2021.03.31 | 
| Nexus bulk upload (Nexus 대량 업로드) (0) | 2020.12.05 |