ah-s3-jenkins

0.1.0 • Public • Published

Anthill AWS S3 / Jenkins Module

build status coverage report

This module makes it easy to integrate with the artifacts generated from Anthill Jenkins jobs.

Usage

Add a config file to your project with AWS info.

Require the module and provide path to the AWS config file from module folder.

Example:

aws_config.json

{ "accessKeyId": "XXXXXXXXXXXXXX", "secretAccessKey": "XXXXXXXXXXXXXXXXXXXX", "region": "eu-central-1" }
var s3 = require('ah-s3-jenkins')('../../aws_config.json');

s3.getJobs('demoBucket', 'my-jenkins-project', function(err, jobs) {
    console.log('Jenkins jobs for project', jobs);
});

API

getJobs(bucket, project, next)

List all the jobs for a project.

The project parameter is the Jenkins project name.

Example output:

[ 'jobs/acme-placebo-2016/20/',
  'jobs/acme-placebo-2016/21/' ]

getSignedUrl(bucket, key, next)

Get a signed url for a PDF report.

The key parameter is the AWS file key, e.g. 'jobs/acme-placebo-2016/21/pdf/report.pdf'.

Example:

s3.getSignedUrl('demoBucket', 'jobs/acme-placebo-2016/21/pdf/report.pdf', function(err, url) {
  console.log('Signed URL for report', url);
});

getMetaData(bucket, key, next)

Get a signed url for a PDF report.

The key parameter is the AWS file key, e.g. 'jobs/acme-placebo-2016/21/pdf/report.pdf'.

Example:

s3.getMetaData('demoBucket', 'jobs/acme-placebo-2016/21/pdf/report.pdf', function(err, data) {
  console.log('Signed URL for report', data);
});

Example of meta-data returned:

{ AcceptRanges: 'bytes',
  LastModified: 'Fri, 24 Feb 2017 08:01:20 GMT',
  ContentLength: '17477366',
  ETag: '"9d5025edc4f1ddbe6b3787d9d462cb6a-4"',
  ContentType: 'application/pdf',
  Metadata: {} }

Test

Config

Add AWS key and secret to config_template.json file and rename the file to config.json.

Run

Normal test run:

npm test

Coverage info:

npm run cover

Readme

Keywords

Package Sidebar

Install

npm i ah-s3-jenkins

Weekly Downloads

0

Version

0.1.0

License

ISC

Last publish

Collaborators

  • jofan