1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-29 06:34:08 +00:00
catalog/task/jenkins/0.1
Yulia Gaponenko f4708d478e Add linux/amd64 platform annotation to the rest of the tasks
At this moment all tasks which can be executed on linux/s390x or
linux/ppc64le are tested and labelled accordingly.
The rest of the tasks can be labelled as `linux/amd64`, which
is default platform and where tasks are already tested via
default PR testing cycle.

Signed-off-by: Yulia Gaponenko <yulia.gaponenko1@de.ibm.com>
2021-10-29 17:08:38 +01:00
..
samples Add a more generic jenkins task 2020-10-26 10:20:20 +00:00
tests jenkins: Add set +x to script. 2021-04-12 22:10:40 +01:00
jenkins.yaml Add linux/amd64 platform annotation to the rest of the tasks 2021-10-29 17:08:38 +01:00
README.md Add linux/amd64 platform annotation to the rest of the tasks 2021-10-29 17:08:38 +01:00

Jenkins Task

The following task can be used to interact with Jenkins using the Jenkins REST API.

More details on Remote Access API can be found here

Install the Task

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/jenkins/0.1/jenkins.yaml

Parameters

  • JENKINS_HOST_URL: The URL on which Jenkins is running (Required)
  • JENKINS_SECRETS: The name of the secret containing the username and API token for authenticating the Jenkins (Default: jenkins-credentials) (Required)
  • ARGS: Extra arguments to add to the control script. (Required)

The arguments are :

  1. start: Start a new Jenkins job.
start [--file-to-upload FILE_TO_UPLOAD] [--wait-started] [--wait-finished] job [job_parameters [job_parameters ...]]
positional arguments:
  job - The job name
  job_parameters - Optional: The parameters to add i.e: key=value

optional arguments:
  --file-to-upload FILE_TO_UPLOAD
                        The path of the file to upload to job.
  --wait-started        Wether to wait for the job to be started.
  --wait-finished       Wether to wait for the job to be finished.

log: Get log of a jenkins build.

log [-h] [--output-file OUTPUT_FILE] job [build_number]

positional arguments:
  job - The job name
  build_number - The build number, use 'lastBuild' to get the latest build

optional arguments:
  --output-file OUTPUT_FILE
                        The location where to save logs on the filesystem. (i.e: a workspace location)

Results

  • build_number: This will output the current jenkins build_number of the job.

Workspaces

  • source: In case any file needs to be provided or saved by the Jenkins Job. (Default: emptyDir: {})

Secrets

Secrets containing username,API token that are used in the task for making the REST API request.

apiVersion: v1
kind: Secret
metadata:
  name: jenkins-credentials
type: Opaque
stringData:
  username: username
  apitoken: api-token

Platforms

The Task can be run on linux/amd64 platform.

Usage

  1. Start a job without parameters

    apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    metadata:
      name: jenkins-job-run
    spec:
      taskRef:
        name: jenkins
      params:
        - name: JENKINS_HOST_URL
          value: "http://localhost:8080"
        - name: ARGS
          value: ["start",  "job"]
      workspaces:
        - name: source
          emptyDir: {}
    
  2. Start job with the parameters param=value and wait that it finishes.

    apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    metadata:
      name: jenkins-job-run
    spec:
      taskRef:
        name: jenkins
      params:
        - name: JENKINS_HOST_URL
          value: "http://localhost:8080"
        - name: ARGS
          value: ["start",  "--wait-finished", "test", "param=value"]
      workspaces:
        - name: source
          emptyDir: {}