All Projects → carlossg → jenkinsfile-runner-lambda

carlossg / jenkinsfile-runner-lambda

Licence: Apache-2.0 license
Run Jenkinsfiles in AWS Lambda

Programming Languages

java
68154 projects - #9 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to jenkinsfile-runner-lambda

pipeline-as-code-with-jenkins
Pipeline as Code with Jenkins
Stars: ✭ 56 (+7.69%)
Mutual labels:  jenkins, lambda
aws-pipeline
Build a CI/CD for Microservices and Serverless Functions in AWS ☁️
Stars: ✭ 32 (-38.46%)
Mutual labels:  jenkins, lambda
lambda-ci
CI/CD for Lambda Functions with Jenkins
Stars: ✭ 20 (-61.54%)
Mutual labels:  jenkins, lambda
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+76.92%)
Mutual labels:  jenkins, lambda
one-click-microservice
A starting point for automating the creation of microservices and all its Ops costs with a single click.
Stars: ✭ 27 (-48.08%)
Mutual labels:  jenkins
serverless-certificate-creator
serverless plugin to manage the certificate of your lambdas custom domain (API Gateway=
Stars: ✭ 33 (-36.54%)
Mutual labels:  lambda
aws-node-custom-user-pool
Serverless AWS Cognito Custom User Pool Example
Stars: ✭ 15 (-71.15%)
Mutual labels:  lambda
caesar
持续集成
Stars: ✭ 40 (-23.08%)
Mutual labels:  jenkins
community-edition
Zebrunner is a Test Automation Management Tool
Stars: ✭ 171 (+228.85%)
Mutual labels:  jenkins
jenkins-client-java
Java实现的对Jenkins操作
Stars: ✭ 28 (-46.15%)
Mutual labels:  jenkins
lambda-runtime-pypy3.5
AWS Lambda Runtime for PyPy 3.5
Stars: ✭ 17 (-67.31%)
Mutual labels:  lambda
windows-slave-installer-module
Windows Agent Installer module for Jenkins
Stars: ✭ 12 (-76.92%)
Mutual labels:  jenkins
lambda-lite-js
a tiny FUNCITONAL LANGUAGE implemented by javascript. 一个函数式语言,使用 js 实现。
Stars: ✭ 77 (+48.08%)
Mutual labels:  lambda
ebs-snapshot-lambda
AWS lambda function to snapshot EBS volumes and purge old snapshots.
Stars: ✭ 37 (-28.85%)
Mutual labels:  lambda
kafka-connect-jenkins
Kafka Connect Connector for Jenkins Open Source Continuous Integration Tool
Stars: ✭ 29 (-44.23%)
Mutual labels:  jenkins
matrix-auth-plugin
Matrix-based authorization strategies for Jenkins
Stars: ✭ 40 (-23.08%)
Mutual labels:  jenkins
serverless-image-rendering
Image delivery with AWS Lambda ⚡
Stars: ✭ 43 (-17.31%)
Mutual labels:  lambda
vacomall
☀️☀️ 基于 dubbo 实现的分布式电商平台。
Stars: ✭ 42 (-19.23%)
Mutual labels:  jenkins
iot-button-ec2-controller
Allows the start/stop of EC2 instances using an AWS IoT button
Stars: ✭ 23 (-55.77%)
Mutual labels:  lambda
FancyDialog
Kotlin + DSL风格代替传统的Builder模式 诸多可配置项 高阶函数代替自定义回调接口 书写起来超级顺手
Stars: ✭ 24 (-53.85%)
Mutual labels:  lambda

Jenkinsfile Runner for AWS Lambda

An AWS Lambda function to run Jenkins pipelines. It will process a GitHub webhook, git clone the repository and execute the Jenkinsfile in that git repository. It allows huge scalability with 1000+ concurrent builds and pay per use with zero cost if not used.

This function allows Jenkinsfile execution without needing a persistent Jenkins master running in the same way as Jenkins X Serverless, but using AWS Lambda instead of Kubernetes. All the logs are stored in AWS CloudWatch and are easily accessible.

Why???

Why not?

I mean, it could make sense to run Jenkinsfiles in Lambda when you are building AWS related stuff, like creating an artifact and uploading it to S3.

Limitations

Lambda limitations:

  • 15 minutes execution time
  • 3008MB of memory
  • git clone and generated artifacts must fit in the 500MB provided

Current implementation limitations:

  • checkout scm does not work, change it to sh 'git clone https://github.com/carlossg/jenkinsfile-runner-lambda-example.git'
  • Jenkinsfile must add /usr/local/bin to PATH and use /tmp for any tool that needs writing files, see the example

Example

See the [jenkinsfile-runner-lambda-example] project for an example that is tested and works.(https://github.com/carlossg/jenkinsfile-runner-lambda-example)

Extending

Three lambda layers are created:

  • jenkinsfile-runner: the main library
  • plugins: minimal set of plugins to build a Jenkinsfile
  • tools: git, openjdk, maven

You can add your plugins in a new layer as a zip file inside a plugins dir to be expanded in /opt/plugins. You could also add the Configuration as Code plugin and configure the Artifact Manager S3 to store all your artifacts in S3.

Other tools can be added as new layers, and they will be expanded in /opt. You can find a list of scripts for inspiration in the lambci project (gcc,go,java,php,python,ruby,rust) and bash, git and zip (git is already included in the tools layer here)

The layers are built with Docker, installing jenkinsfile-runner, tools and plugins under /opt which is where Lambda layers are expanded. These files are then zipped for upload to Lambda.

Installation

Create a lambda function jenkinsfile-runner using Java 8 runtime. Use the layers built in target/layer-* and target/jenkinsfile-runner-lambda-*.jar as function. Could use make publish to create them.

Set

  • handler: org.csanchez.jenkins.lambda.Handler::handleRequest
  • memory: 1024MB
  • timeout: 15 minutes
aws lambda create-function \
    --function-name jenkinsfile-runner \
    --handler org.csanchez.jenkins.lambda.Handler::handleRequest \
    --zip-file fileb://target/jenkinsfile-runner-lambda-1.0-SNAPSHOT.jar \
    --runtime java8 \
    --region us-east-1 \
    --timeout 900 \
    --memory-size 1024 \
    --layers output/layers.json

Exposing the Lambda Function

From the lambda function configuration page add a API Gateway trigger. Select Create a new API and choose the security level. Save the function and you will get a http API endpoint.

Note that to achieve asynchronous execution (GitHub webhooks execution will time out if your webhook takes too long) you would need to configure API Gateway to send the payload to SNS and then lambda to listen to SNS events. See an example.

GitHub events

Add a GitHub json webhook to your git repo pointing to the lambda api gateway url.

Building

make

Publishing

Once the lambda function jenkinsfile-runner is created

make publish

Development

docker build -t csanchez/jenkinsfile-runner-lambda .
docker run -ti --rm -v `pwd`/demo:/workspace -w /workspace csanchez/jenkinsfile-runner-lambda

Testing

curl -v -H "Content-Type: application/json" --data '@src/test/resources/github.json' https://AAAABBBBCCCC.execute-api.us-east-1.amazonaws.com/default/jenkinsfile-runner

Getting the logs

awslogs get /aws/lambda/jenkinsfile-runner ALL --watch
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].