Code Monkey home page Code Monkey logo

rancher-for-ci's Introduction

Rancher for CI

Because I needed a plugin that could upgrade only a given service's docker image version.

Attention: This pluging supports only Rancher Environment API v1.

Parameters

  • endpoint: the environment API endpoint
  • access key: a valid environment API access key
  • secret key: a valid environment API secret key
  • service: the services which you want to upgrade
  • version: the version to which you want to upgrade

Using as a node module

Install it (yarn add @eclass/rancher-for-ci or npm i -s @eclass/rancher-for-ci) then use as in the example below:

const Rancher = require('@eclass/rancher-for-ci')

const client = new Rancher(
  'https://rancher.domain.com/v1/projects/{ID}',
  'MyAccessKey',
  'MySecretKey'
)

;(async () => {
    await client.upgrade('my-stack/my-service', '1.0.0')
})()

Using as a Drone CI plugin

pipeline:
    deploy:
        image: rwillians/rancher-for-ci
        service: my-stack/my-service
        version: latest
        secrets: [ rancher_url, rancher_access_key, rancher_secret_key ]
 pipeline:
     deploy:
         image: rwillians/rancher-for-ci
         service: my-stack/my-service
-        version: latest
+        version: v1.0.10
+        version_prefix: v
         secrets: [ rancher_url, rancher_access_key, rancher_secret_key ]
pipeline:
    deploy:
        image: rwillians/rancher-for-ci
        endpoint: https://rancher.domain.com/v1/projects/{ID}
        access_key: MyAccessKey
        secret_key: MySecretKey
        service: my-stack/my-service
        version: 2.0.1-rc.1

Overriding verson on drone deploy command

You can override the "verion" property buy passing a "VERSION" parameter to deploy command. drone deploy owner/repo {BUILD} {ENVIRONMENT} -p VERSION=2.0.0.

Using DRONE_TAG/CI_TAG as version

If you omit "version" propperty and do not pass the override version parameter, the plugin will try to use "DRONE_TAG" and "CI_TAG" as version.

 pipeline:
     deploy:
         image: rwillians/rancher-for-ci
         service: my-stack/my-service
-        version: v1.0.10
         version_prefix: v
         secrets: [ rancher_url, rancher_access_key, rancher_secret_key ]

drone deploy owner/repo {BUILD} {ENVIRONMENT}

Note that you should use a build resultant of a tag event, otherwise there won't be any "DRONE_TAG" or "CI_TAG" which will result in failure.

All properties

service (required)

The service name which will be upgraded, e.g.: service-name or stack-name/service-name.

version (optional)

Version to which you want to upgrade your service, e.g: v1.0.1.

This value can also be acquired from the environment variables VERSION, PLUGIN_VERSION, DRONE_TAG, CI_TAG and DRONE_COMMIT_REF.

version_prefix (optional)

Remove the version prefix, e.g.: if set to "v", then a version "v1.0.0" will become "1.0.0".

release_variable (required)

Adds an environment variable to Rancher containing the release version, eg: SENTRY_RELEASE.

commit_variable (required)

Adds an environment variable to Rancher containing the commit reference, eg: SENTRY_GIT_COMMIT.

log_instructions (optional)

Allow to log instructions sent to rancher (true or false), which might expose sensitive information.

endpoint (optional)

Rancher api url for the environment you want to upgrade, e.g.: https://rancher.domain.com/v1/.

This value can also be acquired from the environment variable RANCHER_URL.

access_key (optional)

Access key for the given Rancher api environment, e.g.: FF4D832E2045B894577C.

This value can also be acquired from the environment variable RANCHER_ACCESS_KEY.

secret_key (optional)

Secret key for the given Rancher api environment, e.g.: XhwN2HCvYppbQQqgXNurmZLrrjGHhg81s2yETMCi.

This value can also be acquired from the environment variable RANCHER_SECRET_KEY.

Development

Build

docker build -t rancher-for-ci .

Run

docker run -ti \
    -e "PLUGIN_ENDPOINT=$RANCHER_URL" \
    -e "PLUGIN_ACCESS_KEY=$RANCHER_ACCESS_KEY" \
    -e "PLUGIN_SECRET_KEY=$RANCHER_SECRET_KEY" \
    -e PLUGIN_SERVICE=my-stack/my-service \
    -e PLUGIN_VERSION=v1.0.0 \
    -e PLUGIN_VERSION_PREFIX=v \
    -e PLUGIN_RELEASE_VARIABLE=SENTRY_RELEASE \
    -e PLUGIN_COMMIT_VARIABLE=SENTRY_GIT_COMMIT \
    -e DRONE_COMMIT_REF=c0deb10c4 \
    -e PLUGIN_LOG_INSTRUCTIONS=1 \
    rancher-for-ci --dry-run

rancher-for-ci's People

Contributors

dependabot[bot] avatar lgaticaq avatar renovate-bot avatar renovate[bot] avatar rwillians avatar semantic-release-bot avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

miraries

rancher-for-ci's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Cannot push to the Git repository.

semantic-release cannot push the version tag to the branch master on the remote Git repository with URL https://x-access-token:[secure]@github.com/eclass/rancher-for-ci.git.

This can be caused by:


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): replace dependency eslint-plugin-node with eslint-plugin-n 14.0.0
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update dependency @eclass/eslint-config to v4
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-plugin-array-func to v5
  • chore(deps): update dependency eslint-plugin-jsdoc to v48
  • chore(deps): update dependency eslint-plugin-promise to v6
  • chore(deps): update dependency eslint-plugin-security to v3
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency node to v20
  • πŸ” Create all rate-limited PRs at once πŸ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v2
  • actions/setup-node v1
  • actions/cache v1
  • actions/checkout v2
  • actions/setup-node v1
  • actions/cache v1
npm
package.json
  • axios ^0.27.0
  • lodash.merge ^4.6.0
  • p-whilst ^2.1.0
  • @commitlint/cli 8.3.6
  • @commitlint/config-conventional 8.3.6
  • @eclass/eslint-config 2.0.1
  • @eclass/semantic-release-npm-github-config 3.0.1
  • @semantic-release/changelog 5.0.1
  • @semantic-release/git 9.0.1
  • @types/axios 0.14.0
  • @types/lodash.merge 4.6.7
  • eslint 7.32.0
  • eslint-plugin-array-func 3.1.8
  • eslint-plugin-eslint-comments 3.2.0
  • eslint-plugin-import 2.27.5
  • eslint-plugin-jsdoc 30.7.13
  • eslint-plugin-node 11.1.0
  • eslint-plugin-promise 4.3.1
  • eslint-plugin-security 1.7.1
  • eslint-plugin-sonarjs 0.19.0
  • eslint-plugin-standard 4.1.0
  • husky 4.3.8
  • lint-staged 10.5.4
  • prettier-standard 16.4.1
  • semantic-release 17.4.7
nvm
.nvmrc
  • node 12.22.12

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

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.