Commit e7847310 authored by Malin, James (Contractor) Christopher's avatar Malin, James (Contractor) Christopher
Browse files

Created metadata.js to create metadata.json

parent 2e0497dd
Pipeline #877 passed with stages
in 37 seconds
......@@ -58,41 +58,21 @@ stages:
# - publish-image
- trigger_deploy
# ADD IN METADATA.json for tagging, etc.
# stage('Build Image') {
# def info = [:]
# def pkgInfo = readJSON file: 'package.json'
# info.version = pkgInfo.version
# info.branch = SCM_VARS.GIT_BRANCH
# info.commit = SCM_VARS.GIT_COMMIT
# info.image = IMAGE_VERSION
# // Convert from Map --> JSON
# info = readJSON text: groovy.json.JsonOutput.toJson(info)
# writeJSON file: 'metadata.json', pretty: 4, json: info
# // Build candidate image for later penetration testing
# ansiColor('xterm') {
# sh """
# docker build \
# --build-arg FROM_IMAGE=${BASE_IMAGE} \
# --build-arg BUILD_IMAGE=${BUILDER_IMAGE} \
# -t ${LOCAL_IMAGE} \
# .
# """
# }
# }
init:
initialize:
stage: init
image: node:latest
script:
- export APP_TEST=test
- for env in "${!APP_@}"; do printf '%s=%s\n' "$env" "${!env}"; done;
# - for env in "${!APP_@}"; do printf 'MY_ARRAY+=(%s=%s)\n' "$env" "${!env}"; done;
# - for env in "${!APP_@}"; do printf '%s=%s\n' "$env" "${!env}"; done;
# - for i in "${MY_ARRAY_#[@]}"; do echo "$i"; done
# - for env in "${!APP_@}"; do echo "$env"="${!env}" >> test.txt; done;
- node metadata.js ${branch} ${CI_COMMIT_SHA} ${IMAGE_VERSION}
- cat temp-metadata.json
artifacts:
paths:
- temp-metadata.json
###### Build ######
build:
......@@ -104,7 +84,8 @@ build:
- rm package-lock.json
script:
- echo "Building..."
- mv temp-metadata.json metadata.json
- cat metadata.json
# # build a local directory to be used later for testing or deploying
# - mkdir docker-images
# # build image and save
......@@ -114,9 +95,11 @@ build:
# Needed later when loading docker images
# Could test without the docker images saved and try to pull local image
# artifacts:
# paths:
# - docker-images
artifacts:
paths:
# - docker-images
- temp-metadata.json
- metadata.json
# cache:
# key: "$CI_BUILD_REF_NAME"
# paths:
......@@ -214,19 +197,9 @@ build:
# paths:
# - docker-images
# trigger container master job
trigger deploy:
stage: trigger_deploy
# trigger: ghsc/hazdev/container-deploy
# variables:
# BUILD_ID: '$BUILD_ID'
# BUILD_TEST_1: '$$BUILD_ID'
# BUILD_TEST_2: '${BUILD_ID}'
# BUILD_TEST_3: '$${BUILD_ID}'
# BUILD_TEST_4: '{$BUILD_ID}'
# BUILD_TEST_5: $BUILD_ID
# BUILD_TEST_6: $$BUILD_ID
# BUILD_TEST_7: ${BUILD_ID}
# BUILD_TEST_8: $${BUILD_ID}
image: node:latest
when: manual
only:
......@@ -250,5 +223,4 @@ trigger deploy:
-F "variables[REMOTE_DEPLOY_DIR]=${REMOTE_DEPLOY_DIR}"
https://code.chs.usgs.gov/api/v4/projects/1955/trigger/pipeline'
# use triggers with Jenkins config
# use triggers w/ container master
\ No newline at end of file
# use triggers with Jenkins config
\ No newline at end of file
var outputLocation = require("path").resolve(__dirname, "temp-metadata.json");
var pjson = require('./package.json');
var jsonInput = { "version":pjson.version, "branch":process.argv[0], "commit":process.argv[1], "image":process.argv[2] };
require("fs").writeFile(outputLocation, JSON.stringify(jsonInput, null, 5), function(err) {
if(err) {
console.log(err);
} else {
console.log("JSON saved to "+outputLocation);
}
});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment