Unable to configure the Jenkins/CI to connect with gitlab: "Expecting a valid secret token"
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- There is an open issue introduced in the Jenkins's plugin: Gitlab Branch Source plugin since the 1.5.2 version affecting to the CI integration in Liferay Cloud.
- You can find this issue if you are trying to move from another provider to Gitlab, or if you are already using a Gitlab repository and upgrades your CI to a version including a plugin's version >= 1.5.2
The error in the CI logs looks like:
For new Gitlab integrations
Jul 02 15:05:58.331 build-3 [ci-0] SEVERE: Failed to initialize Jenkins
Jul 02 15:05:58.331 build-3 [ci-0] hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
at hudson.WebAppMain$3.run(WebAppMain.java:312)
Caused by: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:49)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1164)
at jenkins.model.Jenkins.<init>(Jenkins.java:962)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:295)
....
Caused by: java.lang.NullPointerException
at io.jenkins.plugins.gitlabbranchsource.GitLabHookCreator.isTokenEqual(GitLabHookCreator.java:231)
at io.jenkins.plugins.gitlabbranchsource.GitLabHookCreator.createWebHookWhenMissing(GitLabHookCreator.java:222)
at io.jenkins.plugins.gitlabbranchsource.GitLabHookCreator.register(GitLabHookCreator.java:97)
at io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.afterSave(GitLabSCMSource.java:731)
at io.jenkins.scm.GitlabSCMSourceConfiguration.getSCMSource(GitlabSCMSourceConfiguration.java:70)
at io.jenkins.init.SetupJob._setBranchSource(SetupJob.java:166)
at io.jenkins.init.SetupJob.setupJob(SetupJob.java:59)
... 14 more
For existent Gitlab connections
Jul 7, 11:40:05.305 build-431 [ci-0] INFO: project/main #1 completed: FAILURE
Jul 7, 12:02:54.861 build-431 [ci-0] Jul 07, 2021 10:02:54 AM io.jenkins.plugins.gitlabbranchsource.GitLabWebHookAction isValidToken
Jul 7, 12:02:54.861 build-431 [ci-0] WARNING: Error while validating token: null
Jul 7, 12:02:54.866 build-431 [ci-0] Jul 07, 2021 10:02:54 AM hudson.init.impl.InstallUncaughtExceptionHandler handleException
Jul 7, 12:02:54.866 build-431 [ci-0] WARNING: Caught unhandled exception with ID af361268-2a9c-487f-8450-223eb5837ba6
Jul 7, 12:02:54.866 build-431 [ci-0] java.lang.Exception: Expecting a valid secret token
at org.kohsuke.stapler.HttpResponses.error(HttpResponses.java:91)
at io.jenkins.plugins.gitlabbranchsource.GitLabWebHookAction.doPost(GitLabWebHookAction.java:75)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
...
at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
at io.jenkins.plugins.gitlabbranchsource.GitLabWebHookAction.process(GitLabWebHookAction.java:49)
...
Environment
- Only Liferay Cloud projects using a Gitlab repository.
- Affected CI versions:
liferaycloud/jenkins:2.277.4-4.2.3
liferaycloud/jenkins:2.277.4-4.2.2
Resolution
- The Liferay Cloud team is working in a solution. Meanwhile you can apply a workaround and downgrade the plugin to a working version. For this you can follow the next steps:
1. Configure the CI image version liferaycloud/jenkins:2.249.3-4.2.1 in your ci/LCP.json
2. Configure a new volume to run a clean installation setting a new label for the volume name in the ci/LCP.json:
"volumes": {
"ciDataNew": "/var/jenkins_home"
},
Note: You will lose your builds information in the Jenkins but you will recover the CI service. Keep in mind that the build list will continue in the Liferay Cloud's web console, and they will continue being accesible and working.
3. Delete the CI service from the DXP Cloud web console, this is necessary when you are changing the volume to a "StatefulSet" service.
4. Deploy the changes in the infra environment using the Command Line Tool: Run lcp deploy from the ci/ folder and select your infra environment.
Did this article resolve your issue ?