-1

I'm using git checkout as

checkout scmGit(
    branches: [[name: 'stable-3.x']],
    userRemoteConfigs: [[url: 'https://github.com/jenkinsci/git-plugin.git']])

I need to set an environment variable which should be used in a post-checkout hooks.

I tried with environment {MY_ENV=1}, withEnv(['MY_ENV=1']).

But the plugin ignores everything.

Michael
  • 1,014
  • 2
  • 15
  • 26

1 Answers1

0

you can configure environment credentials or without and configure something like this in checkout.

environment {
    ManifestRepoUrl='https://gitgerrit.com/test'
    GitHTTPSCredentials='Gitcreddev'
 }
 checkout([
    $class: 'GitSCM',
    branches:
    [[name: "review"]],
    userRemoteConfigs: [[credentialsId: GitHTTPSCredentials,url: ManifestRepoUrl]]
  • This is not what I need. I need an env variable to be visible from the post-checkout hook which is executed by the "checkout" plugin. – Michael Jul 20 '23 at 02:07
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 22 '23 at 17:59