Last active
July 10, 2020 12:44
-
-
Save rochejul/5e020248b47ccbf29578a5dac521c2d7 to your computer and use it in GitHub Desktop.
Groovy script for Jenkins, for "Inject environment variables to the build process" to retrieve the version of the current package.json file (for NodeJs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.json.JsonSlurper | |
import jenkins.* | |
import jenkins.model.* | |
import hudson.* | |
import hudson.model.* | |
def build = Thread.currentThread().executable | |
def inputFile = new File(build.workspace.toString() + "/package.json") | |
def InputJSON = new JsonSlurper().parseText(inputFile.text) | |
def map = [PACKAGE_VERSION: InputJSON.version] | |
return map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exposed as "PACKAGE_VERSION" environment variable