Giter Site home page Giter Site logo

concourse-scp-ssh-resource's Introduction

scp-ssh-resource

A Concourse resource to run commands on hosts or copy files to them using SSH or SCP. This resource is based on https://github.com/Karunamon/concourse-ssh-scp-resource, but supports adding a custom port. I could not get the changes to work in Python so rewrote it in PHP. It also changes the format of the files to upload.

Resource Configuration

All items are required, and go under the source key:

  • user: SSH username
  • host: Host to log into
  • port: Port to connect to (default: 22)
  • verbose: Whether to print verbose output (default: "false")
  • private_key: Private key for user

Behavior

  • check: Not implemented
  • get: Not implemented
  • put: Run a command or copy a file to the configured user@host

SCP

To copy files, add the files key to params, and under it, pass a list of file pairs (prefixed with a -) to copy with : as the separator between source and destination. It is recommended to quote both the source and destination to avoid any YAML parsing surprises. The source directory should be an output name from a previous build step. This is represented in the example as outfiles. The destination directory should be an absolute path (beginning with a /).

- put: scp-ssh-resource
  params:
    files:
      - "outfiles/index.html:/var/www/public_html/index.html"
      - "outfiles/page.html:/var/www/public_html/page.html"

To run commands, add the commands key to params, and under that, give the commands to run as list items (prefixed with a -). Again, quotes are recommended to avoid YAML surprises. Note that all commands run in a && chain from top to bottom, so failure or a nonzero exit of any command will result in all later commands on this step not executing.

- put: scp-ssh-resource
  params:
    commands:
      - "ls /var/www/public_html"
      - "free -m"
      - "/bin/false"
      - "/bin/true"  # Will not run

You may copy files and run commands as part of the same step. Note that file copies will always be run first.

params:
  files:
    - "outfiles/main.py:/var/www/public_html/main.py"
  commands:
    - 'ls /var/www/public_html`
    - `md5sum /var/www/public_html/*`
    - `systemctl restart nginx`

Installation

Add a new resource type to your pipeline:

resource_types:
- name: ssh-scp
  type: registry-image
  source:
    repository: meezaan/concourse-ssh-scp-resource

Then, define a resource targeting the system you want to run commands on or copy files to:

resources:
- name: website-html-scp
  type: ssh-scp
  icon: web
  source:
    user: someuser
    host: mywebserver.com
    port: 22
    private_key: |
      -----BEGIN OPENSSH PRIVATE KEY-----
      ...
      -----END OPENSSH PRIVATE KEY-----

Please use a credential manager for your private key, and do not check it into source control.

Thanks

concourse-scp-ssh-resource's People

Contributors

meezaan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.