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

PR environment variables not available during build process #105

Closed
volodymyr-mykhailyk opened this issue Jun 26, 2017 · 14 comments
Closed

Comments

@volodymyr-mykhailyk
Copy link

Hello,

maybe it is a configuration issue, but I don't see any environment variables mentioned in description during build process.

The only item I can see is special is that:

  • we using YAML configuration plugin
  • we using custom named scm materials

Here is piece of yaml configuration:

materials:
  repo:
    scm: repo-name.pull-requests
    destination: repo
  ci-scripts:
    pipeline: ops-builds.ci-scripts
    stage: build

Here is list of environment variables set by GOCD during build process:

14:29:17.443 [go] Start to update materials.
14:29:35.390 [go] overriding environment variable 'GO_SERVER_URL' with value 'https://****:8154/go'
14:29:35.390 [go] setting environment variable 'GO_TRIGGER_USER' to value 'changes'
14:29:35.390 [go] setting environment variable 'GO_PIPELINE_NAME' to value 'repo-name.build--pull-requests'
14:29:35.390 [go] setting environment variable 'GO_PIPELINE_COUNTER' to value '4'
14:29:35.390 [go] setting environment variable 'GO_PIPELINE_LABEL' to value '8f7b322c9c'
14:29:35.390 [go] setting environment variable 'GO_STAGE_NAME' to value 'build'
14:29:35.390 [go] setting environment variable 'GO_STAGE_COUNTER' to value '1'
14:29:35.390 [go] setting environment variable 'GO_JOB_NAME' to value 'build_docker_image'
14:29:35.390 [go] setting environment variable 'GO_DEPENDENCY_LABEL_CI_SCRIPTS' to value '16'
14:29:35.390 [go] setting environment variable 'GO_DEPENDENCY_LOCATOR_CI_SCRIPTS' to value 'ops-builds.ci-scripts/16/build/1'
14:29:35.390 [go] setting environment variable 'GO_SCM_REPO_LABEL' to value '8f7b322c9c408eed89f356808e6d18450efc8446'
14:29:35.390 [go] setting environment variable 'GO_SCM_REPO_URL' to value 'git@github.com:******.git'
14:29:35.390 [go] setting environment variable 'GO_SCM_REPO_PR_ID' to value '1543'

14:29:35.761 [go] Start to build repo-name.build--pull-requests/8f7b322c9c/build/1/build_docker_image on 89c6dcc038f9 [/go]

Any hints why we don't see target branch environment variables?

Thanks in advance

@Hyjaz
Copy link

Hyjaz commented Jun 26, 2017

Hi I have the same problem. I get exactly the same output as @volodymyr-mykhailyk.
I dont have:

PR_BRANCH
TARGET_BRANCH
PR_URL
PR_AUTHOR
PR_AUTHOR_EMAIL
PR_DESCRIPTION

Is there additional configuration to be performe, before it is possible to get these informations?

@ashwanthkumar
Copy link
Owner

Do you all see any information on the plugin logs? My best guess is that ~/.github is not present or configured wrong. I might well be missing something obvious too.

Apart from the logs, please also share the GoCD version and the plugin version you're using.

@Hyjaz
Copy link

Hyjaz commented Jun 27, 2017

Where should I put the ~/.github?? @ashwanthkumar

this is my GoCD version: 17.5.0
this is my plugins versions: 1.3.0-RC2

@ashwanthkumar
Copy link
Owner

@Hyjaz ~/.github goes in ~/ <-- that's the linux shell notation for home folder of the user. So the .github file should inside the home folder of the user that's running the Go process.

@Hyjaz
Copy link

Hyjaz commented Jun 27, 2017

It's working for me, it was because I had added username and password on the material on gocd as well.

@mukeshmurali
Copy link

I am facing the same issue. Any help is really appreciated:

Following are the details:

Go Version: 17.1.0 
Github PR Builder plugin version: 1.3.4 

Available variables:

setting environment variable 'GO_PIPELINE_NAME' to value 'xxxxx'
setting environment variable 'GO_PIPELINE_COUNTER' to value '71'
setting environment variable 'GO_PIPELINE_LABEL' to value 'xxxx'
setting environment variable 'GO_STAGE_NAME' to value 'xxxxx'
setting environment variable 'GO_STAGE_COUNTER' to value '1'
setting environment variable 'GO_JOB_NAME' to value 'xxxxx'
setting environment variable 'GO_SCM_GS_CONSOLE_PR_LABEL' to value 'xxxxx'
setting environment variable 'GO_SCM_GS_CONSOLE_PR_URL' to value 'git@github.xxxxxxx'
setting environment variable 'GO_SCM_GS_CONSOLE_PR_PR_ID' to value '100'

There are no errors in the plugin logs.

The only error in the server logs is the below that is safe to be ignored as per the below post
ashwanthkumar/gocd-slack-build-notifier#43

The gocd server has .github file present in the home folder of the go user with the content as below:

# for enterprise installations - Make sure to add /api/v3 to the hostname
# ignore this field or have the value to https://api.github.com
endpoint=https://<github host name>/api/v3
login=johndoe
oauth=thisaintatoken

@ashwanthkumar
Copy link
Owner

ashwanthkumar commented Dec 20, 2017

@mukeshmurali Just saw this message. On the ~/.github file, I'm hoping you've updated your login and oauth values to actual values and not the dummy ones you've posted right?

@gnikitenko
Copy link

Hello, bumping this issue a bit, because
a) I have the same issue of not having plugin's env variables set during build.
b) having ~/.github set with oauth, so we are actually properly pulling PR's as they happen.

my take on this is that, maybe, in our setup with other plugin - "GitHub OAuth authorization plugin" it simply doesn't work. :-/

@ashwanthkumar
Copy link
Owner

@gnikitenko I would like you to verify the following check-list and make sure you've done all of the below.

  • You've placed the .github in the home folder of go user where you're GoCD server is running.
  • ~/.github file contains username and oauth properties in them.
  • You've not specified a different username / password in the Material's dialog of the pipeline. (If you've saved your GoCD Server's username and password in your Password Manager of your browser, they tend to auto-populate them in here as well).

@ashwanthkumar
Copy link
Owner

@gnikitenko If you've answered Yes to all of the above, let's move this conversation to email (you can find mine on my profile). I would be happy to get on a Skype or Hangouts call to debug this further with you.

@gnikitenko
Copy link

Oh, wow, after i asked our administator about the home folder, he pointed out to me, that GOCD adds his own prefixes to automatically generated EVs, so i had them all along, just by "slightly" longer names.

And i was expecting names, just like in the manual, so that's my fault.

So:

  1. Sorry that i bothered you with my inability to read console logs :-(
  2. Thank you for your great reply, pretty much summs up the ticket.
  3. Thank you very much for your plugins, they help a lot.

@ashwanthkumar
Copy link
Owner

Thanks @gnikitenko.

Closing the issue.

@thejasbabu
Copy link

@ashwanthkumar Is it required that the pipeline definition have username / password mentioned? If someone is depending on creating pipeline through code (via yaml definition), it would require one to check-in the username/password/token to the codebase.

@ashwanthkumar
Copy link
Owner

@thejasbabu No you don't need username / password in the definition. Check out the checklist on #105 (comment), if you answer yes to the first 2 boxes you don't need to check-in username / password in the YAML spec.

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

6 participants