Skip to content

Instantly share code, notes, and snippets.

@atomlab
Created January 7, 2020 12:38
Show Gist options
  • Save atomlab/de8b0b3d186aa32d993ee204abd15610 to your computer and use it in GitHub Desktop.
Save atomlab/de8b0b3d186aa32d993ee204abd15610 to your computer and use it in GitHub Desktop.
Get an environment variables of git plugin in scripting pipeline

Jenkinsfile

node {
  dir ("checkout") {
    scmVars = checkout(scm)
    echo "${scmVars}"
    echo "scmVars.GIT_URL_1: ${scmVars.GIT_URL_1}"
    echo "scmVars.GIT_URL_2: ${scmVars.GIT_URL_2}"
  }
}

Output jenkins log

[Pipeline] echo
scmVarsALL: [GIT_BRANCH:jenkins/master, 
GIT_COMMIT:c0d28448efc43d438073ac1fe71361ccda9e2abc, 
GIT_PREVIOUS_COMMIT:4976b91f876d7db74cdac642b5965d5d877b73b1, 
GIT_PREVIOUS_SUCCESSFUL_COMMIT:c1965e91bdb2f3c18ca795e5f1bedcccf1bffceb, 
GIT_URL_1:git@github.com:owner/my-project-1.git, 
GIT_URL_2:git@github.com:owner/my-project-2.git]
[Pipeline] echo
scmVars.GIT_URL_1: git@github.com:owner/my-project-1.git
[Pipeline] echo
scmVars.GIT_URL_2: git@github.com:owner/my-project-2.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment