Closed yvolodym closed 6 years ago
Did you enable 'Build when a change is pushed to Gogs'? Without it to environment variables are not set.
i changed project from multibranch to pipeline project and activate "Build when a change is pushed to Gogs". Output is the same GOGS_REF: null
@ketyboss The current implementation in the plugin doesn't work properly with the Jenkinsfile. Will release this is the next version of the plugin.
Thanks for information! I'm looking forward to the new release!
@ketyboss You can try to test drive the last snapshot version which can be downloaded here. This version exposes all except the arraylist to environment variables.
Hi. Plugin 1.0.15-SNAPSHOT (private-c49bd6c8-jenkins) Send from Gogs:
{
"ref": "refs/heads/master",
"before": "cb0b65cc80ef8b3030533c6fddc9c17a496f4d67",
"after": "cb0b65cc80ef8b3030533c6fddc9c17a496f4d67",
"compare_url": "",
"commits": [
{
"id": "cb0b65cc80ef8b3030533c6fddc9c17a496f4d67",
"message": "set private smtp port to 250\n",
Jenkinsfile:
stages {
stage('Info') {
steps {
echo "GOGS_REF: " + env.GOGS_REF
echo "BRANCH_NAME: " + env.BRANCH_NAME
echo "BUILD_NUMBER: " + env.BUILD_NUMBER
}
}
Output from Jenkins (Maven Project)
[Pipeline] stage
[Pipeline] { (Info)
[Pipeline] echo
GOGS_REF: null
[Pipeline] echo
BRANCH_NAME: null
[Pipeline] echo
BUILD_NUMBER: 14
[Pipeline] }
[Pipeline] // stage
"Build when a change is pushed to Gogs" ist activ Sorry it's not work properly...
Try this in your steps:
echo sh(script: 'env|sort', returnStdout: true)
It works! But only if the project is set up as a multibranch project. If that is as Maven then there are no GOGS variables in output Multibranch:
GOGS_AFTER=6ea33861ffeee0469663b6ded9320472f7a85657
GOGS_BEFORE=a38c16f435dbb85a10de01e4fce4ac44205a1528
GOGS_COMPARE_URL=https://git.myurl.de/myproject/myproject/compare/a38c16f435dbb85a10de01e4fce4ac44205a1528...6ea33861ffeee0469663b6ded9320472f7a85657
GOGS_PUSHER_AVATAR_URL=https://secure.gravatar.com/avatar/bec6438bb6486860
GOGS_PUSHER_EMAIL=eugen@myurl.de
GOGS_PUSHER_FULL_NAME=Eugen
GOGS_PUSHER_LOGIN=mylogin
GOGS_PUSHER_USERNAME=myusername
GOGS_REF=refs/heads/master
GOGS_REPOSITORY_CLONE_URL=https://git.myurl.de/myproject/myproject.git
GOGS_REPOSITORY_CREATED_AT=2017-10-29T19:10:22+01:00
GOGS_REPOSITORY_DEFAULT_BRANCH=master
GOGS_REPOSITORY_DESCRIPTION=My Repository
GOGS_REPOSITORY_EMPTY=false
GOGS_REPOSITORY_FORK=false
GOGS_REPOSITORY_FULL_NAME=myproject/myproject
GOGS_REPOSITORY_HTML_URL=https://git.myurl.de/myproject/myproject
GOGS_REPOSITORY_MIRROR=false
GOGS_REPOSITORY_NAME=myproject
GOGS_REPOSITORY_OWNER_AVATAR_URL=https://git.myurl.de/avatars/4
GOGS_REPOSITORY_OWNER_FULL_NAME=myproject GmbH
GOGS_REPOSITORY_OWNER_LOGIN=myproject
GOGS_REPOSITORY_OWNER_USERNAME=myproject
GOGS_REPOSITORY_PRIVATE=true
GOGS_REPOSITORY_SSH_URL=ssh://git@git.myurl.de/myproject/myproject.git
GOGS_REPOSITORY_UPDATED_AT=2018-05-14T08:27:39+02:00
GOGS_REPOSITORY_WEBSITE=http://www.myproject.de
GOGS_SENDER_AVATAR_URL=https://secure.gravatar.com/avatar/bec6438bb64868600
GOGS_SENDER_EMAIL=eugen@myurl.de
GOGS_SENDER_FULL_NAME=Eugen
GOGS_SENDER_LOGIN=mylogin
GOGS_SENDER_USERNAME=myusername
HOME=/root
Maven Project - empty blok of GOGS
JSON Output of webhook: { "ref": "refs/heads/master", "before": "8c276adb0dd7b0a4a807166f9f4cc6413f81c0ad", "after": "08785465b1eb8c324ede4d58455c00b5e421f7d7", "compare_url": "https://...", "commits": [ { "id": "08785465b1eb8c324ede4d58455c00b5e421f7d7", "message": "GOGS_REF in environment\n", "url": "https://...", "author": {
.... }
Description
GOGS_REF can't be found in Jenkinsfile (Multibranch Pipeline): stages { stage('Info') { steps { echo "GOGS_REF: " + env.GOGS_REF } }
Output in console: GOGS_REF: null