2017-02-13 22 views
0

私はGit pluginをJenkinsと使用しています。JenkinsにGIT環境変数が表示されない

$GIT_BRANCHという環境変数にアクセスしようとしましたが、nullがあります。私はGroovyのスクリプトを使用して環境変数を印刷したときに続いて、私はNO Gitの環境変数がありました:

[PATH:/Library/Frameworks/Python.framework/Versions/3.5/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Users/octavian/.rvm/gems/ruby-2.2.1/bin:/Users/octavian/.rvm/gems/[email protected]/bin:/Users/octavian/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/spark/bin:/Library/TeX/texbin:/Users/octavian/.rvm/bin:/bin, IRBRC:/Users/octavian/.rvm/rubies/ruby-2.2.1/.irbrc, JAVA_ARCH:x86_64, _system_arch:x86_64, rvm_bin_path:/Users/octavian/.rvm/bin, TERM:xterm-256color, rvm_prefix:/Users/octavian, LANG:en_GB.UTF-8, COMMAND_MODE:unix2003, ITERM_SESSION_ID:w0t3p1:42062586-0BC3-48BB-B563-06F3F0CE98BF, LOGNAME:octavian, rvm_version:1.26.11 (latest), XPC_SERVICE_NAME:0, PWD:/Applications/Jenkins, TERM_PROGRAM_VERSION:3.0.8, SPARK_PATH:/usr/local/lib/spark-2.0.0-bin-hadoop2.7/bin, _:/usr/bin/java, SHELL:/bin/bash, TERM_PROGRAM:iTerm.app, _system_type:Darwin, MY_RUBY_HOME:/Users/octavian/.rvm/rubies/ruby-2.2.1, SECURITYSESSIONID:186a9, _system_version:10.11, OLDPWD:/Applications/Jenkins, USER:octavian, GEM_HOME:/Users/octavian/.rvm/gems/ruby-2.2.1, ITERM_PROFILE:Default, rvm_path:/Users/octavian/.rvm, TMPDIR:/var/folders/d8/dxrq0j_d10s7twghyd6v5tdr0000gn/T/, SSH_AUTH_SOCK:/private/tmp/com.apple.launchd.jnlVvcT4kt/Listeners, RUBY_VERSION:ruby-2.2.1, GEM_PATH:/Users/octavian/.rvm/gems/ruby-2.2.1:/Users/octavian/.rvm/gems/[email protected], XPC_FLAGS:0x0, TERM_SESSION_ID:w0t3p1:42062586-0BC3-48BB-B563-06F3F0CE98BF, _system_name:OSX, __CF_USER_TEXT_ENCODING:0x1F5:0x0:0x0, Apple_PubSub_Socket_Render:/private/tmp/com.apple.launchd.1nXNOoW3kV/Render, com.apple.java.jvmTask:CommandLine, COLORFGBG:7;0, JAVA_MAIN_CLASS_75437:Main, HOME:/Users/octavian, SHLVL:1] 

ジェンキンススクリプトを実行するために、私は前の段階で、Groovy pluginを使用 "システムのGroovyを実行しますスクリプト」と次のコード:

import hudson.model.* 

def env = System.getenv() 

println "env is: " + env 

は、なぜ私はGIT環境変数を見ることができませんか?

答えて

0

これは含まれています "GIT_BRANCH"

def branch = build.getEnvVars()["GIT_BRANCH"] 
println "branch is: " + branch 
関連する問題