Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables are empty #323

Open
zszabo14 opened this issue Apr 21, 2020 · 2 comments
Open

Environment variables are empty #323

zszabo14 opened this issue Apr 21, 2020 · 2 comments

Comments

@zszabo14
Copy link

zszabo14 commented Apr 21, 2020

I'm trying to get plugin related environment variables, but they are NULL. How can I refer on those variables in a Pipeline script (Groovy).

Example:

pipeline {
agent any
	stages {
		stage('Stage 11') {
			steps {
				echo 'Hello world!'
				git(
					url: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
					credentialsId: 'YYYYYYYYYYYYY',
					branch: "WWWWWWWWWWW"
				)
				script{
					echo 'Current Build: ' + currentBuild.displayName
					echo "${env.GITHUB_PR_BODY}"
					echo "${env.GITHUB_PR_TARGET_BRANCH}"
					echo "${env.GITHUB_PR_SOURCE_BRANCH}"
					def changeLogSets = currentBuild.changeSets
					echo 'Change Set size: ' + changeLogSets.size()
					for (int i = 0; i < changeLogSets.size(); i++) {
						def entries = changeLogSets[i].items
						for (int j = 0; j < entries.length; j++) {
							def entry = entries[j]
							echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}"
							echo "msg: " + entry.msg
							echo "pkg: " + entry.msg.substring(entry.msg.indexOf("{")+1, entry.msg.indexOf("}"))
							def files = new ArrayList(entry.affectedFiles)
							for (int k = 0; k < files.size(); k++) {
								def file = files[k]
								echo "  ${file.editType.name} ${file.path}"
							}
						}
					}
				}
			}
		}
	}
} 
@KostyaSha
Copy link
Owner

Variables should be available when build was triggered by this plugin. Try check with shell env command

@zszabo14
Copy link
Author

Yes, it was triggered by this plugin using the git webhook.
I printed out all environment variables: echo sh(returnStdout: true, script: 'env')
None of those are present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants