# Jenkins on StackOS

**Jenkins is a tool used by developers to automate various processes.**

We will show how a basic setup can fail, how to discover the failure, and how to fix the failure.

### References

{% embed url="<https://hub.docker.com/r/jenkins/jenkins>" %}

{% embed url="<https://github.com/jenkinsci/docker/blob/master/README.md>" %}

## ✅ First Launch

Use this image: `jenkins/jenkins:lts-jdk11`

![](/files/KlNkrRmY1gQYqTd1Mgcl)

![](/files/RhfN8PyvmWEl1dIzOF1R)

![](/files/N8pV9V1puCroQsTxwvVM)

## ✅ Initial Setup Results

After your initial setup you will be presented with a URL such as:

<https://jenkins-0xyourethaddress-matrix.stackos.io/>

## ✅ Seeing your first failure

Navigate to the provided URL to see the following message

```
no healthy upstream
```

## ✅ Checking Failure

{% content-ref url="/pages/f8p2oiwMIiPY9bDaaDIJ" %}
[WebTTY, Logs, Shell Access](/stackos-docs/operations/webtty-logs-shell-access.md)
{% endcontent-ref %}

Open a WebTTY and list your pod statuses

You will see that your Jenkins pod is flagged with "CrashLoopBackOff"

This indicates your pod is crashing

## ✅ Determine Nature of Crash

Use the WebTTY to show the pod logs.  In some cases you will see something, in other cases you will not.  It depends on the method used to set up the docker image. &#x20;

`kubectl logs jenkins-0xYourEthAddress`

![](/files/0nPXAbM2jJhgfxLdzO9T)

We have now determined our persistent data is owned by the wrong user. This is common if the pod is running as a user other than root. Determine the owner of the directory, set the ownership properly, and restart.

## ✅ Determining Owner

Navigate to the image details\
<https://hub.docker.com/layers/jenkins/jenkins/latest/images/sha256-aa593c851bdd8ca16c7e546d2fbb191e3dd6bdb960a464b1f844d80431c272ef?context=explore>

![](/files/dbSsw5hN4unaS4dwuAwT)

We now know the user/group should be 1000 / 1000 respectively.

## ✅ Changing Ownership

We use a dummy container image to make an easy shell and change ownership of the data directory

**Temporarily set your pod image to "nginx:latest" and Update your Application**

![](/files/Zp4rq80mvsBzneTCN0u2)

**Shell into your pod**&#x20;

`kubectl exec -ti jenkins-0xYourEthAddress-Random -- bash`

**Change the ownership of the persistent data directory**

`chmod 1000:1000 /var/jenkins_home`

**Verify the new ownership**

```
# ls -al /var/jenkins_home
total 28
drwxr-xr-x 3 1000 1000  4096 Mar 18 13:29 .
drwxr-xr-x 1 root root  4096 Mar 18 13:45 ..
drwx------ 2 root root 16384 Mar 18 13:29 lost+found
```

Change the image back to `jenkins/jenkins:lts-jdk11`

## ✅ Success

Jenkins is now running!

![](/files/YHYxOnzjguvXCSw7A7uh)

## ✅ Obtain your setup password

```
kubectl exec jenkins-0xYourEthAddress-random more /var/jenkins_home/secrets/initialAdminPassword

```

![](/files/XjGoeljdOK3oPtTVrUxw)

**Fill in the password**

![](/files/Nd3q5mPHOW3cAyTX0hUB)

Proceed through the installation steps.  We recommend you take the basic route the first time to get familiar before doing more complex setups.

**Your site is now ready:**

![](/files/FXkrrUPFaiPCigVjCng5)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stackos.io/stackos-docs/app-store-notes/jenkins-on-stackos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
