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

Document skipping initial setup wizard #833

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ docker run -d -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenk

this will run Jenkins in detached mode with port forwarding and volume added. You can access logs with command 'docker logs CONTAINER_ID' in order to check first login token. ID of container will be returned from output of command above.

## Logging in

To access the new Jenkins instance visit http://localhost:8080/ .

You will be presented with an "unlock Jenkins" page prompting for the generated admin password. You can find this printed in the container log (see `docker logs $yourcontainerid`) or with:

docker exec $yourcontainerid cat /var/jenkins_home/secrets/initialAdminPassword

## Backing up data

If you bind mount in a volume - you can simply back up that directory
Expand Down Expand Up @@ -164,6 +172,10 @@ FROM jenkins/jenkins:lts
COPY custom.groovy /usr/share/jenkins/ref/init.groovy.d/custom.groovy

Choose a reason for hiding this comment

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

Suggested change
COPY custom.groovy /usr/share/jenkins/ref/init.groovy.d/custom.groovy
```dockerfile
FROM jenkins/jenkins:lts
COPY custom.groovy /usr/share/jenkins/ref/init.groovy.d/custom.groovy

```

# Automated configuration

Some deployments may wish to minimise manual configuration of their Jenkins instances by preinstalling plugins, preconfiguring environment variables and tools, etc.

## Preinstalling plugins

You can rely on the `install-plugins.sh` script to pass a set of plugins to download with their dependencies.
Expand Down Expand Up @@ -251,13 +263,27 @@ script-security:1.13
...
```

For 2.x-derived images, you may also want to
## Disabling the setup wizard

By default Jenkins runs a setup wizard prompting the user to "unlock Jenkins" with a generated admin password then install plugins. This isn't always desired, particularly if a deployment is intended to be fully automated.

RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
The initial configuration tool may be disabled by passing the system property `-Djenkins.install.runSetupWizard=false`, usually to `docker run` e.g.

to indicate that this Jenkins installation is fully configured.
Otherwise a banner will appear prompting the user to install additional plugins,
which may be inappropriate.
docker run ..otheroptions... --env JAVA_OPTS="-Djenkins.install.runSetupWizard=false" jenkins/jenkins:lts`

This will disable creation of the default admin user and password, and will leave Jenkins in an unsecured configuration where anyone who can connect has full admin rights. So it should generally be coupled with automation to install plugins and to configure the server.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This will disable creation of the default admin user and password, and will leave Jenkins in an unsecured configuration where anyone who can connect has full admin rights. So it should generally be coupled with automation to install plugins and to configure the server.
Unless you use some kind of Configuration-as-Code to configure the instance (Groovy Hooks, JCasC plugin, etc.),
this will disable creation of the default admin user and password, and will leave Jenkins in an unsecured configuration where anyone who can connect has full admin rights. So it should generally be coupled with automation to install plugins and to configure the server.

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, several other security-related settings will not be enabled by default. While I don't think we should provide an exhaustive list that might easily become outdated, it's important to point this out.


Note: Some documentation suggested creating `jenkins.install.UpgradeWizard.state` and/or `jenkins.install.InstallUtil.lastExecVersion`. Using the system property is simpler and more reliable.
Copy link
Member

Choose a reason for hiding this comment

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

it is


## Applying an initial server configuration
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it worth referencing https://speakerdeck.com/onenashev/docker-and-jenkins-as-code or a similar slidedeck


Jenkins may be pre-configured in a number of ways:

* A partial jenkins XML configuration may be copied into the Docker image's `/usr/share/jenkins/ref/config.xml` to serve as a base configuration.
* A tool like the [Configuration as Code plugin](https://github.com/jenkinsci/configuration-as-code-plugin) may be used to manage the configuration declaratively
* Groovy scripts may be automatically executed during deployment as mentioned above

It's very strongly recommended that you configure the server to enable security using one of these methods if you disable the initial setup wizard.

# Upgrading

Expand All @@ -273,6 +299,8 @@ To force upgrades of plugins that have been manually upgraded, run the docker im

The default behaviour when upgrading from a docker image that didn't write marker files is to leave existing plugins in place. If you want to upgrade existing plugins without marker you may run the docker image with `-e TRY_UPGRADE_IF_NO_MARKER=true`. Then plugins will be upgraded if the version provided by the docker image is newer.



## Hacking

If you wish to contribute fixes to this repository, please refer to the [dedicated documentation](HACKING.adoc).
Expand Down