danger / danger/swift

[Jenkins] Multibranch Pipeline: Could not find a CI source for this run

Open
#370 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Swift
Stars
1.1k
Forks
152
Avg merge
9h 54m
Merged PRs (30d)
2

Description

# Report

## What did you do?

Run `danger-swift ci` inside a Multibranch Pipeline's Jenkinsfile sh script (Connecting to Bitbucket Server)

## What did you expect to happen?

Being able to run the Dangerfile and use a bitbucket bot account to post comments in the target PR

## What happened instead?

Although I am setting the Bitbucket Server's host, the account and password of the bot, and also verifying that CHANGE_BRANCH and CHANGE_ID are set on the environment variables, danger-swift keeps reporting that `**Could not find a CI source for this run**` and asking if I am using a CI that is not supported.

## Your Environment

* Jenkins CI
* Danger-swift version: 3.4.1
* Danger version: 10.1.0
* Dangerfile contents (just the sample one):

```ruby
import Danger
let danger = Danger()

// Pull out the edited files and find ones that come from a sub-folder
// where our app lives
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
let editedAppFiles = editedFiles.filter { $0.contains("/App") }

// Let people bail from the CHANGELOG check
let hasSkipChangelog = danger.github.pullRequest.body?.contains("#no_changelog")
let hasSkipChangelogLabel = danger.github.issue.labels.first { $0.name == "Skip Changelog" }
let skipCheck = hasSkipChangelog ?? false || (hasSkipChangelogLabel != nil)

// Request for a CHANGELOG entry with each app change
if editedAppFiles.count > 0 && !skipCheck {
fail("Please add a CHANGELOG entry for these changes. If you would like to skip this check, add `#no_changelog` to the PR
body and re-run CI.")
}

```
* Jenkins script (on Jenkinsfile, using Pipelines):

```
node('ios-slave') {
stage('Clean Clone SCM') {
sh '''
rm -f -r *
git clone -b $CHANGE_BRANCH ssh://git@git.somewhere-it.com:7999/ti/project-ios.git
'''
}

stage('Cocoapods Update') {
withEnv(['LANG=en_US.UTF-8', 'PATH+PODS=/Users/slave/.rbenv/shims/']) {
sh '''
cd project-folder
pod update
'''
}
}

stage('Danger CI') {
withEnv(['DANGER_BITBUCKETSERVER_HOST=https://git.somewhere-it.com/', 'PATH+DANGER=/usr/local/bin/']) {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'My Bitbucket Server Credentials',
usernameVariable: 'DANGER_BITBUCKETSERVER_USERNAME',
passwordVariable: 'DANGER_BITBUCKETSERVER_PASSWORD']]) {
sh '''
cd project-ios
danger-swift ci
'''
}
}
}
}
```

* Environment Variables on Jenkins (printenv):

```
JENKINS_NODE_COOKIE=258328e8-8748-4801-88fd-ae80d386072e
SHELL=/bin/zsh
HUDSON_SERVER_COOKIE=2b6a4abc789835b8
CHANGE_BRANCH=feature/Branch_Name
STAGE_NAME=Danger CI
TMPDIR=/var/folders/__/clhhlm6d5fg7__h0syj9vmtw0000gv/T/
SSH_CLIENT=100.67.120.38 40126 22
BUILD_TAG=jenkins-iOS Danger-PR-665-9
CHANGE_URL=https://git.somewhere-it.com/projects/ti/repos/project-ios/pull-requests/665/overview
BRANCH_NAME=PR-665
OLDPWD=/Users/slave/Jenkins-agent/workspace/Branch_Name
WORKSPACE=/Users/slave/Jenkins-agent/workspace/Branch_Name
RUN_CHANGES_DISPLAY_URL=http://unconfigured-jenkins-location/job/iOS%20Danger/job/PR-665/9/display/redirect?page=changes
USER=slave
com.apple.java.jvmTask=CommandLine
CHANGE_AUTHOR=Tanabe, Alex
CHANGE_TITLE=WIP: Dangerfile.swift added
__CF_USER_TEXT_ENCODING=0x1FB:0x0:0x0
CHANGE_TARGET=develop
EVEREST_GOOGLE_MAP_KEY=AIzaSyCOCe-j1eywf596mhVfxpyhTr_TihQIkq8
JENKINS_HOME=/var/jenkins_home
PATH=/usr/local/bin/:/usr/bin:/bin:/usr/sbin:/sbin
RUN_DISPLAY_URL=http://unconfigured-jenkins-location/job/iOS%20Danger/job/PR-665/9/display/redirect
CHANGE_ID=665
PWD=/Users/slave/Jenkins-agent/workspace/ProjectName-665/repo
JOB_NAME=iOS Danger/PR-665
BUILD_DISPLAY_NAME=#9
BUILD_ID=9
JOB_BASE_NAME=PR-665
SHLVL=2
HOME=/Users/slave
EXECUTOR_NUMBER=7
JENKINS_SERVER_COOKIE=durable-ce4efe6484d2e6ca4193099e92758ca5
NODE_LABELS=ios-slave
DANGER_BITBUCKETSERVER_PASSWORD=****
LOGNAME=slave
DANGER_BITBUCKETSERVER_HOST=https://git.somewhere-it.com/
CHANGE_AUTHOR_EMAIL=****@somewhere.com
HUDSON_HOME=/var/jenkins_home
SSH_CONNECTION=100.67.120.38 40126 10.48.15.194 22
NODE_NAME=ios-slave
JOB_DISPLAY_URL=http://unconfigured-jenkins-location/job/iOS%20Danger/job/PR-665/display/redirect
BUILD_NUMBER=9
HUDSON_COOKIE=6f04de97-a6d7-46d9-b463-ecee252d4448
JAVA_ARCH=x86_64
DANGER_BITBUCKETSERVER_USERNAME=****
JAVA_MAIN_CLASS_32098=hudson.remoting.Launcher
```

Note: I am trying to hide sensitive information, but the overall structure of the information is here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.