npm package: @spmeesseman/jenkins-utility-server
Description: Jenkins CI Utility Server
Author: Scott Meesseman
Latest version: 1.0.1

# Jenkins Utility Server

[![app-type](https://img.shields.io/badge/category-dev%20env-blue.svg)](https://www.perryjohnson.com)
[![app-lang](https://img.shields.io/badge/language-javascript%20c%23%20php%20python%20c-blue.svg)](https://www.perryjohnson.com)
[![app-publisher](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-app--publisher-e10000.svg)](https://issues.pjats.com/set_project.php?project=Gapp-publisher&make_default=no)

[![authors](https://img.shields.io/badge/authors-scott%20meesseman-6F02B5.svg?logo=visual%20studio%20code)](https://github.com/perryjohnsoninc)
[![MantisBT issues open](https://issues.pjats.com/plugins/ApiExtend/api/issues/countbadge/jenkins-utility-server/open)](https://issues.pjats.com/set_project.php?project=jenkins-utility-server&make_default=no&ref=plugin.php?page=Releases/releases)
[![MantisBT issues closed](https://issues.pjats.com/plugins/ApiExtend/api/issues/countbadge/jenkins-utility-server/closed)](https://issues.pjats.com/set_project.php?project=jenkins-utility-server&make_default=no&ref=plugin.php?page=Releases/releases)
[![MantisBT version current](https://issues.pjats.com/plugins/ApiExtend/api/versionbadge/jenkins-utility-server/current)](https://issues.pjats.com/set_project.php?project=jenkins-utility-server&make_default=no&ref=plugin.php?page=Releases/releases)
[![MantisBT version next](https://issues.pjats.com/plugins/ApiExtend/api/versionbadge/jenkins-utility-server/next)](https://issues.pjats.com/set_project.php?project=jenkins-utility-server&make_default=no&ref=plugin.php?page=Releases/releases)

- [Jenkins Utility Server](#jenkins-utility-server)
  - [Introduction](#introduction)
  - [Requirements](#requirements)
  - [Installation](#installation)
  - [Run the Server](#run-the-server)
  - [Usage](#usage)
  - [Endpoints](#endpoints)
    - [Endpoints - /openfile](#endpoints---openfile)
  - [License Information](#license-information)

## Introduction

Jenkins Utility Server is a HTTP server that runs on a Jenkins node, that can serve user interface tasks via a pipeline script using a simple HTTP request.

At the time of this writing and for the initial release, only one task is supported - "open file in notepad".

## Requirements

Jenkins HTTP Request Plugin

## Installation

To install `Jenkins Utility Server` from a command line, run the following command:

    npm install -g @perryjohnson/jenkins-utility-server

## Run the Server

Run the `Jenkins Utility Server` from a command line using the following command:

    jenkins-utility-server

By default, the bound port number is 4322.  To change the bound port number, use the following command:

    jenkins-utility-server --port 6000

## Usage

Simply add a request to a pipeline script invoking `httpRequest` on the appropriate endpoint, for example:

    steps {
      echo "Jenkins-utility-server: Send request to open changelog in Notepad"
      def jsonEncWs = WORKSPACE.replace("\\", "\\\\")
      def bodyJson = "{\"path\": \"${jsonEncWs}\\\\CHANGELOG.md\", \"token\": \"${env.JENKINS_UTILITY_SERVER_TOKEN}\"}"
      httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: bodyJson, url: "http://localhost:4322/openfile"
    }

## Endpoints

Endpoints are called by sending a request to the server with the following address format:

    http://localhost:portnumber/endpointname

At the time of this writing and for the initial release, only one task is supported - "open file in notepad".

### Endpoints - /openfile

Usage:

    steps {
      echo "Jenkins-utility-server: Send request to open history file in Notepad"
      def jsonEncWs = WORKSPACE.replace("\\", "\\\\")
      def bodyJson = "{\"path\": \"${jsonEncWs}\\\\doc\\\\history.txt\", \"token\": \"${env.JENKINS_UTILITY_SERVER_TOKEN}\"}"
      httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: bodyJson, url: "http://localhost:4322/openfile"
    }

## License Information

Licensed under MIT, see the [LICENSE](LICENSE.md)