octopus-deploy
Version:
Node scripts to package up applications, create releases, and deploy with Octopus Deploy. This package leverages the Octopus Deploy REST API in order to deploy from Windows and non-Windows machines.
28 lines (20 loc) • 649 B
JavaScript
const api = require('../api')
const { logger, setApiConfig, getApiConfig } = require('../utils')
const setSpaceByName = async name => {
if (!name) {
return
}
const queryResult = await api.spaces.findAll()
const spaces = queryResult.valueOrDefault([])
const space = spaces.find(x => x.name === name)
if (!space) {
logger.error(`Space '${name}' not found`)
throw new Error(`Unable to set space '${name}'`)
}
const { id: spaceId } = space
logger.info(`Using Space '${spaceId}' (${name})`)
const config = getApiConfig()
setApiConfig({ ...config, spaceId })
}
module.exports.execute = setSpaceByName