# Jenkins (Pipeline)

<figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2FP27bvKHxXhATQyaeBUd4%2Fjenkins-svg.svg?alt=media&#x26;token=f43161a3-c331-476d-b89d-5b6cf6222958" alt=""><figcaption></figcaption></figure>

Jenkins is the leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.

You can use our [jenkins](https://plugins.jenkins.io/tacotruck-plugin) plugin in your pipeline script.

### &#x20;Jenkins Installation with Docker

1. Create a bridge network in Docker

```sh
docker network create jenkins
```

2. Run a `docker:dind` Docker image

```sh
docker run --name jenkins-blueocean --restart=on-failure --detach \
  --network jenkins --env DOCKER_HOST=tcp://docker:2376 \
  --env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
  --publish 8080:8080 --publish 50000:50000 \
  --volume jenkins-data:/var/jenkins_home \
  --volume jenkins-docker-certs:/certs/client:ro \
  myjenkins-blueocean:2.516.3-1
```

3. Create a Dockerfile

```sh
FROM jenkins/jenkins:2.516.3-jdk21
USER root
RUN apt-get update && apt-get install -y lsb-release ca-certificates curl && \
    install -m 0755 -d /etc/apt/keyrings && \
    curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
    chmod a+r /etc/apt/keyrings/docker.asc && \
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
    https://download.docker.com/linux/debian $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" \
    | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
    apt-get update && apt-get install -y docker-ce-cli && \
    apt-get clean && rm -rf /var/lib/apt/lists/*
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow json-path-api"
```

4. Build the docker image from the above Dockerfile and assign a tag such as `myjenkins-blueocean:2.516.3-1`

```sh
docker build -t myjenkins-blueocean:2.516.3-1 .
```

5. Run your image as container

```sh
docker run --name jenkins-blueocean --restart=on-failure --detach \
  --network jenkins --env DOCKER_HOST=tcp://docker:2376 \
  --env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
  --publish 8080:8080 --publish 50000:50000 \
  --volume jenkins-data:/var/jenkins_home \
  --volume jenkins-docker-certs:/certs/client:ro \
  myjenkins-blueocean:2.516.3-1
```

6. Complete the setup [wizard](https://www.jenkins.io/doc/book/installing/docker/#setup-wizard)

### Install Node.js Plugin

Tacotruck plugin requires nodejs as dependency. Login to your jenkins dasboard and go to the settings page. Plugins are available at <http://localhost:8080/manage/pluginManager/available> this path. You can search for Nodejs plugin. Select the plugin and install.

<figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2Fpw0yZrW1ihqRb52VOSeH%2Fjenkins-available-plugin.webp?alt=media&#x26;token=a9a1f17d-89d3-4d28-a74e-033961e2060e" alt=""><figcaption></figcaption></figure>

### Configure Nodejs as Global Tool

1. Go to settings and click on tools section.

<figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2Fb1Eiz0xv91Se719h5wx8%2Fjenkins-settings-page.png?alt=media&#x26;token=4c699ec0-eae8-4ee6-8459-a53e36879d9a" alt=""><figcaption></figcaption></figure>

2. Click on "Add Nodejs" button

<figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2FqB2APEXfyS4EwRm1TcPK%2Fconfigure-nodejs-tool.webp?alt=media&#x26;token=0d6097ea-156e-4656-a59a-1c86b2fc1357" alt=""><figcaption></figcaption></figure>

3. Install a Nodejs version. Please make sure that you install node **version** ≥ <mark style="color:red;">`20`</mark>. You need to name the Tool so that we can refer it later from the pipeline script.

<figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2FHqXRk1A6Wcpu6qJLwSqA%2Fconfigure-nodejs-tools-section.webp?alt=media&#x26;token=f50fef15-11bb-4aef-b790-4b8f78e9c2a8" alt=""><figcaption></figcaption></figure>

### Install Tacotruck Jenkins Plugin

Go to the "Available Plugins" section on the settings page and search for "Tacotruck" to install.

<figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2FW13MIfPJXqjn7Tw6x90f%2Fimage.png?alt=media&#x26;token=ec484b3b-56b8-45a2-94bd-9dc204222fc0" alt=""><figcaption></figcaption></figure>

### Tacotruck Pipeline Script

```groovy
pipeline {
    agent any
    tools {
        nodejs '22.8.0'
    }
    stages {
        stage('Build') {
            steps {
                echo 'Building ..'
            }
        }
        stage('Test') {
            steps {
                echo 'Running Test ..'
            }
        }
        stage('Submit Test Results') {
            steps {
                tacotruck(
                    provider: 'testfiesta',
                    runName: 'My TacoTruck Run',
                    apiUrl: 'https://staging.api.testfiesta.com',
                    handle: 'TestHandle',
                    project: 'testProjectKey',
                    credentialsId: 'YOUR_CREDENTIALS_ID',
                    resultsPath: './test-results.xml'
                    source: "Jenkins CI"
                )
            }
        }
    }
}
```

You can see the documentation for Tacotruck jenkins plugin [here](https://docs.testfiesta.com/). For `credentialsId`  parameter you can see the documentation for using credentials in jenkins [here](https://www.jenkins.io/doc/book/using/using-credentials/).

### Support and Resources

* [TacoTruck Examples](https://github.com/testfiesta/tacotruck-examples)
* [Jenkins Plugin](https://plugins.jenkins.io/tacotruck)
* [Jenkins Plugin Source](https://github.com/jenkinsci/tacotruck-plugin)
* [Tacotruck Issues](https://github.com/testfiesta/tacotruck/issues)
* [**CLI Reference**](https://docs.testfiesta.com/automation/tacotruck-cli)
