19. Jenkins FAQ

This section provides answers to the most frequently asked questions about using Jenkins with Spring Cloud Pipelines.

Pipeline version contains ${PIPELINE_VERSION}

You can check the Jenkins logs and see the following warning:

WARNING: Skipped parameter `PIPELINE_VERSION` as it is undefined on `jenkins-pipeline-sample-build`.
	Set `-Dhudson.model.ParametersAction.keepUndefinedParameters`=true to allow undefined parameters
	to be injected as environment variables or
	`-Dhudson.model.ParametersAction.safeParameters=[comma-separated list]`
	to whitelist specific parameter names, even though it represents a security breach

To fix it, you have to do exactly what the warning suggests. Also, you should ensure that the Groovy token macro processing checkbox is set.

Pipeline version is not passed to the build

You can see that the Jenkins version is properly set. However, in the build version, it is still snapshot and the echo "${PIPELINE_VERSION}" does not print anything.

You can check the Jenkins logs and see the following warning:

WARNING: Skipped parameter `PIPELINE_VERSION` as it is undefined on `jenkins-pipeline-sample-build`.
	Set `-Dhudson.model.ParametersAction.keepUndefinedParameters`=true to allow undefined parameters
	to be injected as environment variables or
	`-Dhudson.model.ParametersAction.safeParameters=[comma-separated list]`
	to whitelist specific parameter names, even though it represents a security breach

To fix it, you have to do exactly what the warning suggests.

The build times out with pipeline.sh information

This is a Docker compose issue. The problem is that for some reason, only in Docker, the execution of Java hangs. However, it hangs randomly and only the first time you try to run the pipeline.

The solution to this issue is to run the pipeline again. If it passes once, it will pass for any subsequent build.

Another thing that you can try is to run it with plain Docker. That helps sometimes.

Can I use the pipeline for some other repositories?

Yes. You can pass the REPOS variable with a comma-separated list of project_name$project_url format. If you do not provide the PROJECT_NAME, the repository name is extracted and used as the name of the project.

For example, a REPOS value equal to https://github.com/spring-cloud-samples/github-analytics,https://github.com/spring-cloud-samples/github-webhook results in the creation of pipelines with root names github-analytics and github-webhook.

For example, a REPOS equal to myanalytics$https://github.com/spring-cloud-samples/github-analytics,myfeed$https://github.com/spring-cloud-samples/atom-feed results in the creation of pipelines with root names myanalytics for github-analytics and myfeed for github-webhook.

Can this work for ANY project out of the box?

Not really. This is an “opinionated pipeline”. That is why we took some opinionated decisions, such as:

  • Using Spring Cloud, Spring Cloud Contract Stub Runner, and Spring Cloud Eureka.
  • Application deployment to Cloud Foundry.
  • Maven, including:

    • Using the Maven Wrapper.
    • Artifacts deployment by using ./mvnw clean deploy.
    • The stubrunner.ids property to retrieve the list of collaborators for which stubs should be downloaded.
    • Running smoke tests on a deployed app with the smoke Maven profile.
    • Running end to end tests on a deployed app with the e2e Maven profile.
  • Gradle (in the github-analytics application check in the gradle/pipeline.gradle file), including:

    • Using the Gradlew Wrapper.
    • A deploy task for artifacts deployment.
    • Running smoke tests on a deployed application with the smoke task.
    • Running end to end tests on a deployed application with the e2e task.
    • A groupId task to retrieve group ID.
    • An artifactId task to retrieve artifact ID.
    • A currentVersion task to retrieve the current version.
    • A stubIds task to retrieve the list of collaborators for which stubs should be downloaded.

      This is the initial approach that can be easily changed in the future.

Can I modify this to reuse in my project?
Yes. It is open-source. The important thing is that the core part of the logic is written in Bash scripts. That way, in the majority of cases, you could change only the bash scripts without changing the whole pipeline.
The rollback step fails due to a missing JAR

You must have pushed some tags and have removed the Artifactory volume that contained them. To fix this, remove the tags by using the following command:

git tag -l | xargs -n 1 git push --delete origin
I want to provide a different JDK version.
  • By default, we assume that you have configured a JDK with an ID of jdk8.
  • If you want a different one, override the JDK_VERSION environment variable to point to the proper one.


    The docker image comes in with Java installed at /usr/lib/jvm/java-8-openjdk-amd64. You can go to Global Tools and create a JDK with an ID of jdk8 and set JAVA_HOME to /usr/lib/jvm/java-8-openjdk-amd64.

To change the default settings, follow the steps shown in the following images:

Figure 19.1. Click 'Manage Jenkins'

manage jenkins

Figure 19.2. Click 'Global Tool'

global tool

Figure 19.3. Click 'JDK Installations'

jdk installation

Figure 19.4. Fill out JDK Installation with path to your JDK


How can I enable groovy token macro processing?
We scripted that. However, if you need to this manually, follow the steps shown in the following images:

Figure 19.5. Click 'Manage Jenkins'

manage jenkins

Figure 19.6. Click 'Configure System'

configure system

Figure 19.7. Click 'Allow token macro processing'

groovy token

How can I make deployment to stage and prod be automatic?

Set the relevant property or environment variable to true:

  • AUTO_DEPLOY_TO_STAGE to automatically deploy to stage.
  • AUTO_DEPLOY_TO_PROD to automatically deploy to prod.
How can I skip testing API compatibility?
Set the API_COMPATIBILITY_STEP_REQUIRED environment variable to false and re-run the seed (you can pick it from the seed job’s properties, too).
I can’t tag the repo.

You may get an error similar to the following:

19:01:44 stderr: remote: Invalid username or password.
19:01:44 fatal: Authentication failed for 'https://github.com/marcingrzejszczak/github-webhook/'
19:01:44 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1740)
19:01:44 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1476)
19:01:44 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
19:01:44 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$8.execute(CliGitAPIImpl.java:1816)
19:01:44 	at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:295)
19:01:44 	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
19:01:44 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
19:01:44 	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
19:01:44 	at hudson.model.Build$BuildExecution.post2(Build.java:185)
19:01:44 	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
19:01:44 	at hudson.model.Run.execute(Run.java:1745)
19:01:44 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
19:01:44 	at hudson.model.ResourceController.execute(ResourceController.java:98)
19:01:44 	at hudson.model.Executor.run(Executor.java:404)

Most likely, you passed a wrong password. Check the credentials section for how to update your credentials.

I am unauthorized to deploy infrastructure jars.
Most likely, you forgot to update your local settings.xml file with the Artifactory’s setup. Check out this section of the docs and update your settings.xml file.
Signing Artifacts
In some cases, it may be required that, when you perform a release, that the artifacts be signed before you push them to the repository. To do this, you need to import your GPG keys into the Docker image that runs Jenkins. This can be done by placing a file called public.key that contains your public key and a file called private.key that contains your private key in the seed directory. These keys are imported by the init.groovy script runs when Jenkins starts.
Using SSH keys for Git

The seed job checks whether an environment variable called GIT_USE_SSH_KEY is set to true. If it is true, the environment variable called GIT_SSH_CREDENTIAL_ID is chosen as the one that contains the ID of the credential that contains SSH private key. By default, GIT_CREDENTIAL_ID is picked as the one that contains the username and password to connect to git.

You can set these values in the seed job by filling out the form and toggling a checkbox.

Deploy to stage fails and does not redeploy a service (Kubernetes).
There can be a number of reasons for this issue. Remember, though, that, for stage, we assume that a sequence of manual steps needs to be performed. We do not redeploy any existing services, because, most likely, you deliberately have it set up that way. If, in the logs of your application, you can see that you cannot connect to a service, first ensure that the service is forwarding traffic to a pod. Next, if that is not the case, delete the service and re-run the step in the pipeline. That way, Spring Cloud Pipelines redeploy the service and the underlying pods.
I ran out of resources. (Cloud Foundry)

[jenkins-cf-resources]] When deploying the application to stage or prod, you can get an Insufficient resources exception. The way to solve it is to kill some applications from the test and stage environments. To do so, run the following commands:

cf target -o pcfdev-org -s pcfdev-test
cf stop github-webhook
cf stop github-eureka
cf stop stubrunner

You can also run ./tools/cf-helper.sh kill-all-apps to remove all demo-related apps deployed to PCF Dev.

Deploying to test or stage or prod fails with an error about finding space (Cloud Foundry)

You receive an exception similar to the following:

20:26:18 API endpoint:   https://api.local.pcfdev.io (API version: 2.58.0)
20:26:18 User:           user
20:26:18 Org:            pcfdev-org
20:26:18 Space:          No space targeted, use 'cf target -s SPACE'
20:26:18 FAILED
20:26:18 Error finding space pcfdev-test
20:26:18 Space pcfdev-test not found

It means that you forgot to create the spaces in your PCF Dev installation.

The route is already in use (Cloud Foundry).

If you play around with Jenkins and Concourse, you can end up with routes that are already occupied, as identified by errors similar to the following:

Using route github-webhook-test.local.pcfdev.io
Binding github-webhook-test.local.pcfdev.io to github-webhook...
The route github-webhook-test.local.pcfdev.io is already in use.

To resolve the issue, delete the offending routes, by using commands similar to the following:

yes | cf delete-route local.pcfdev.io -n github-webhook-test
yes | cf delete-route local.pcfdev.io -n github-eureka-test
yes | cf delete-route local.pcfdev.io -n stubrunner-test
yes | cf delete-route local.pcfdev.io -n github-webhook-stage
yes | cf delete-route local.pcfdev.io -n github-eureka-stage
yes | cf delete-route local.pcfdev.io -n github-webhook-prod
yes | cf delete-route local.pcfdev.io -n github-eureka-prod

You can also run the ./tools/cf-helper.sh delete-routes script.

How can I run helper scripts against a real Cloud Foundry instance that I’m logged into?

Assuming that you are already logged into the cluster, uyou can run the helper script with the REUSE_CF_LOGIN=true env variable, as shown in the following example:

REUSE_CF_LOGIN=true ./tools/cf-helper.sh setup-prod-infra

This script create the MySQL database and the RabbitMQ service and downloads and deploys Eureka to the space and organization you are logged into.