Skip to content

Files

Latest commit

2996b3c · Dec 11, 2019

History

History
61 lines (47 loc) · 1.81 KB

README.md

File metadata and controls

61 lines (47 loc) · 1.81 KB

jenkins-pipeline-aws-shared-lib

This project provides easy AWS shared library which can be used into Jenkins pipeline. References:

Setup instructions

In Jenkins, go to Manage Jenkins → Configure System. Under Global Pipeline Libraries, add a library with the following settings:

Then create a Jenkins job with the following pipeline (note that the underscore _ is not a typo):

@Library('jenkins-pipeline-aws-shared-lib')_

def aws = new com.jenkins.aws.Pipeline()

docker.image('garland/aws-cli-docker').inside {
    withAWS(credentials: 'aws-credentials',region: 'us-east-1'){
                    
        stage('Get or create ECS cluster'){
            ecrLogin = aws.awsECRGetLogin()
            println ecrLogin
        }
    }
}

Or:

@Library('jenkins-pipeline-aws-shared-lib') import com.jenkins.aws.Pipeline

def aws = new Pipeline()

//...

For template utils use:

@Library('jenkins-pipeline-aws-shared-lib') _ 

def template = new com.jenkins.utis.Template()

node {
    stage('Generate worker from template'){
                def binding = [:]
                binding.workerId    = "12345"
                binding.workerName  = "Tomer"

    
                def templateFile = "worker.template"
                def dstFile      = "worker.json"
                template.createFromTemplate(templateFile, binding ,dstFile)
    }
}