Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Remove no longer required secret push token for Jenkins setups #9317

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 42 additions & 29 deletions docs/dev/setup/jenkins-gitlab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -485,48 +485,48 @@ do either do it manually or using the following command:

2. You can now first build and deploy Jenkins, then you can also start the other services which weren't started yet:

.. code:: bash
.. code:: bash

JAVA_OPTS=-Djenkins.install.runSetupWizard=false docker compose -f docker/<Jenkins setup to be launched>.yml up --build -d jenkins
docker compose -f docker/<Jenkins setup to be launched>.yml up -d
JAVA_OPTS=-Djenkins.install.runSetupWizard=false docker compose -f docker/<Jenkins setup to be launched>.yml up --build -d jenkins
docker compose -f docker/<Jenkins setup to be launched>.yml up -d

Jenkins is then reachable under ``http://localhost:8082/`` and you can login using the credentials specified
in ``jenkins-casc-config-gitlab.yml`` (defaults to ``artemis_admin`` as both username and password).

3. The `application-local.yml` must be adapted with the values configured in ``jenkins-casc-config-gitlab.yml``:

.. code:: yaml

artemis:
user-management:
use-external: false
internal-admin:
username: artemis_admin
password: artemis_admin
version-control:
url: http://localhost:8081
user: artemis_admin
password: artemis_admin
continuous-integration:
user: artemis_admin
password: artemis_admin
url: http://localhost:8082
vcs-credentials: artemis_gitlab_admin_credentials
artemis-authentication-token-key: artemis_notification_plugin_token
artemis-authentication-token-value: artemis_admin
.. code:: yaml

5. Open the ``src/main/resources/config/application-jenkins.yml`` and change the following:
artemis:
user-management:
use-external: false
internal-admin:
username: artemis_admin
password: artemis_admin
version-control:
url: http://localhost:8081
user: artemis_admin
password: artemis_admin
continuous-integration:
user: artemis_admin
password: artemis_admin
url: http://localhost:8082
vcs-credentials: artemis_gitlab_admin_credentials
artemis-authentication-token-key: artemis_notification_plugin_token
artemis-authentication-token-value: artemis_admin

4. Open the ``src/main/resources/config/application-jenkins.yml`` and change the following:
Again, if you are using a development setup, the template in the beginning of this page already contains the
correct values.

.. code:: yaml
.. code:: yaml

jenkins:
internal-urls:
ci-url: http://jenkins:8080
vcs-url: http://gitlab:80
jenkins:
internal-urls:
ci-url: http://jenkins:8080
vcs-url: http://gitlab:80

6. You're done. You can now run Artemis with the GitLab/Jenkins environment.
5. You're done. You can now run Artemis with the GitLab/Jenkins environment.

Manual Jenkins Server Setup
"""""""""""""""""""""""""""
Expand Down Expand Up @@ -691,6 +691,18 @@ Start Jenkins
user: your.chosen.username
password: your.chosen.password

11. In a local setup, you have to disable CSRF otherwise some API endpoints will return HTTP Status 403 Forbidden.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is not new, but got lost when removing the secret push token section in #9266.

This is done be executing the following command:
``docker compose -f docker/<Jenkins setup to be launched>.yml exec -T jenkins dd of=/var/jenkins_home/init.groovy < docker/jenkins/jenkins-disable-csrf.groovy``

The last step is to disable the ``use-crumb`` option in ``application-local.yml``:

.. code:: yaml

jenkins:
use-crumb: false


Required Jenkins Plugins
""""""""""""""""""""""""

Expand Down Expand Up @@ -858,6 +870,7 @@ GitLab Repository Access
continuous-integration:
vcs-credentials: the.id.of.the.username.and.password.credentials.from.jenkins


Upgrading Jenkins
"""""""""""""""""

Expand Down
9 changes: 0 additions & 9 deletions docs/dev/setup/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ You can override the following configuration options in this file.
user: <username> # e.g. ga12abc
token: <token> # Enter a valid token generated by the CI system or leave this empty to use the fallback authentication user + password
password: <password>
# Some CI systems, like Jenkins, offer a specific token that gets checked against any incoming notifications
# from a VCS trying to trigger a build plan. Only if the notification request contains the correct token, the plan
# is triggered. This can be seen as an alternative to sending an authenticated request to a REST API and then
# triggering the plan.
# In the case of Artemis, this is only really needed for the Jenkins + GitLab setup, since the GitLab plugin in
# Jenkins only allows triggering the Jenkins jobs using such a token. Furthermore, in this case, the value of the
# hudson.util.Secret is stored in the build plan, so you also have to specify this encrypted string here and NOT the actual token value itself!
# You can get this by GETting any job.xml for a job with an activated GitLab step and your token value of choice.
secret-push-token: <token hash>
# Key of the saved credentials for the VCS service
# Jenkins: You have to specify the key from the credentials page in Jenkins under which the user and
# password for the VCS are stored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public class JenkinsBuildPlanCreator implements JenkinsXmlConfigBuilder {

private static final String REPLACE_SOLUTION_CHECKOUT_PATH = "#solutionCheckoutPath";

private static final String REPLACE_PUSH_TOKEN = "#secretPushToken";

private static final String REPLACE_ARTEMIS_NOTIFICATION_URL = "#notificationsUrl";

private static final String REPLACE_NOTIFICATIONS_TOKEN = "#jenkinsNotificationToken";
Expand All @@ -62,9 +60,6 @@ public class JenkinsBuildPlanCreator implements JenkinsXmlConfigBuilder {

private String artemisNotificationUrl;

@Value("${artemis.continuous-integration.secret-push-token}")
private String pushToken;

@Value("${artemis.continuous-integration.vcs-credentials}")
private String gitCredentialsKey;

Expand Down Expand Up @@ -97,7 +92,7 @@ public Document buildBasicConfig(final ProgrammingLanguage programmingLanguage,
final String jenkinsfile = getJenkinsfile(internalVcsRepositoryURLs, programmingLanguage, checkoutSolution, buildPlanUrl);

final Path configFilePath = Path.of("templates", "jenkins", "config.xml");
final var configFileReplacements = Map.of(REPLACE_PIPELINE_SCRIPT, jenkinsfile, REPLACE_PUSH_TOKEN, pushToken);
final var configFileReplacements = Map.of(REPLACE_PIPELINE_SCRIPT, jenkinsfile);
final var xmlResource = resourceLoaderService.getResource(configFilePath);
return JenkinsXmlFileUtils.readXmlFile(xmlResource, configFileReplacements);
}
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/config/application-artemis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ artemis:
password: <password>
token: <token> # Enter a valid token generated in the CI system giving Artemis full Admin access
url: <url>
# Some CI systems, like Jenkins, offer a specific token that gets checked against any incoming notifications
# from a VCS trying to trigger a build plan. Only if the notification request contains the correct token, the plan
# is triggered. This can be seen as an alternative to sending an authenticated request to a REST API and then
# triggering the plan.
# In the case of Artemis, this is only really needed for the Jenkins + GitLab setup, since the GitLab plugin in
# Jenkins only allows triggering the Jenkins jobs using such a token. Furthermore, in this case, the value of the
# hudson.util.Secret is stored in the build plan, so you also have to specify this encrypted string here and NOT the actual token value itself!
# You can retrieve this by getting any job.xml for a job with an activated GitLab step and your token value of choice.
secret-push-token: <token hash>
# Key of the saved credentials for the VCS service
# GitLab CI: not needed
# Jenkins: You have to specify the key from the credentials page in Jenkins under which the user and
Expand Down
30 changes: 0 additions & 30 deletions src/main/resources/templates/jenkins/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,6 @@
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin">
<gitLabConnection>GitLab</gitLabConnection>
</com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
<triggers>
<com.dabsquared.gitlabjenkins.GitLabPushTrigger plugin="gitlab-plugin">
<spec></spec>
<triggerOnPush>true</triggerOnPush>
<triggerOnMergeRequest>false</triggerOnMergeRequest>
<triggerOnPipelineEvent>false</triggerOnPipelineEvent>
<triggerOnAcceptedMergeRequest>false</triggerOnAcceptedMergeRequest>
<triggerOnClosedMergeRequest>false</triggerOnClosedMergeRequest>
<triggerOnApprovedMergeRequest>false</triggerOnApprovedMergeRequest>
<triggerOpenMergeRequestOnPush>never</triggerOpenMergeRequestOnPush>
<triggerOnNoteRequest>false</triggerOnNoteRequest>
<noteRegex>Jenkins please retry a build</noteRegex>
<ciSkip>true</ciSkip>
<skipWorkInProgressMergeRequest>true</skipWorkInProgressMergeRequest>
<setBuildDescription>true</setBuildDescription>
<branchFilterType>All</branchFilterType>
<includeBranchesSpec></includeBranchesSpec>
<excludeBranchesSpec></excludeBranchesSpec>
<sourceBranchRegex></sourceBranchRegex>
<targetBranchRegex></targetBranchRegex>
<secretToken>{#secretPushToken}</secretToken>
<pendingBuildName></pendingBuildName>
<cancelPendingBuildsOnUpdate>false</cancelPendingBuildsOnUpdate>
</com.dabsquared.gitlabjenkins.GitLabPushTrigger>
</triggers>
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
</properties>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="[email protected]">
<script>#pipelineScript</script>
Expand Down
1 change: 0 additions & 1 deletion src/test/resources/config/application-artemis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ artemis:
password: fake-password
token: fake-token
url: https://continuous-integration.fake.fake
secret-push-token: fake-token-hash
vcs-credentials: fake-key
artemis-authentication-token-key: fake-key
artemis-authentication-token-value: fake-token
Expand Down
Loading