0

I want to run Danger test on the CI that runs on Jenkins. I'm using scripted pipelines. I have installed the GitHub branch source plug-in into Jenkins. I have also created a personal access token to the builds_user account (that Jenkins uses for GitHub interaction), and stored this in the Jenkins credential store, with unique ID builds_user_repos_acces.

This is the way I'm running danger:

withCredentials([usernamePassword(credentialsId: 'builds_user_repos_access', passwordVariable: 'DANGER_GITHUB_API_TOKEN', usernameVariable: '')]) {
   def dangerEnv = [
      "DANGER_GITHUB_API_TOKEN=${env.DANGER_GITHUB_API_TOKEN}"
   ]
   stage('danger') {
      withEnv(buildEnv + dangerEnv) {
         sh 'bundle exec danger'
      }
   }
}

The buildEnv is a list of env variable that I need to run ruby gems. Everything works when I run other gems and when I run bundle install.

what I get is a warning:

  • bundle exec danger

Not a Jenkins Pull Request - skipping 'danger' run.

I have also tried:

      stage('danger') {
         withEnv(buildEnv) {
            withCredentials([usernamePassword(credentialsId: 'skbuilds_repos_access', passwordVariable: 'DANGER_GITHUB_API_TOKEN', usernameVariable: '')]) {
               sh 'env'
               sh "bundle exec danger"
            }
         }
      }

And I can see that the DANGER_GITHUB_API_TOKEN is there (masked).

Do you see what is wrong? Is there a way to get more info?

kingston
  • 11,053
  • 14
  • 62
  • 116

1 Answers1

0

Danger works only with pull request, so you have to make multibranch or github organization job in jenkins and connect jenkinsFile.

hoi
  • 2,168
  • 20
  • 22