Skip to content

Jenkins job

  • A job is a task to be performed
  • Show job:
  • List of all built-in envs

Create job

  • Create job:
  • Give it any name
  • Freestyle project

Trigger

  • A job can be triggered manually at
  • If an execution fails it will show as a red ball
  • Cronjobs can also be configured to trigger automatically

External trigger

  • To trigger externally, permissions must be set in order to trigger
  • Invoke with a crumb!
  • CSRF protection must be enabled under in order to generate a crumb
# Get a jenkins-crumb token!
crumb=curl "http://localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,':',//crumb)" -u "admin:123"

# Trigger job with a crumb (no parameters)
curl -X "POST" "http://localhost:8080/job/job-name/build?delay=0sec" -u "admin:123" -H "$crumb"

# Trigger job with a crumb (with parameters)
curl -X "POST" "http://localhost:8080/job/job-name/buildWithParameters?DB_HOST=db&DB_NAME=testdbql" -u "admin:123" -H "$crumb"
# Trigger job with a token (no parameters)
curl "http://localhost:8080/job/job-name/build?token=mytoken" -u "admin:123"  # Token is configured in the item configuration

# Trigger job with a token (with parameters)
curl "http://localhost:8080/job/job-name/buildWithParameters?token=mytoken&DB_HOST=db&DB_NAME=testdbql" -u "admin:123"

Job DSL

  • It's a good practice to version your DSL in a git repository
  • This way, your seed job cab be builded automatically (via git hooks) every time a DSL is updated in the git repository
  • Building the seed job with the updated DSL will update the child job
  • For that script security for Job DSL scripts must be disabled under
  • This option enabled prevents DSL from being loaded from a local file

Pipelines

  • A multi-branch pipeline is a "folder" generates a job for each git branch that contains a pipeline