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

Error on updating existing job #362

Closed
traviseret opened this issue Aug 26, 2015 · 3 comments · Fixed by #396
Closed

Error on updating existing job #362

traviseret opened this issue Aug 26, 2015 · 3 comments · Fixed by #396
Labels
bug Something isn't working
Milestone

Comments

@traviseret
Copy link

When I am trying to update an existing jenkins job with this module, I get an error during the agent run.

Code:

jenkins::job { 'bounce-apache':
    config => template('ha_jenkins_sandbox/bounce-apache/config.xml.erb'),
}

Error:

Info: Applying configuration version '766ab92'
Error: cat "/tmp/bounce-apache-config.xml" | java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8081 create-job "bounce-apache" returned 255 instead of one of [0]
Error: /Stage[main]/Ha_jenkins_sandbox/Jenkins::Job[bounce-apache]/Jenkins::Job::Present[bounce-apache]/Exec[jenkins create-job bounce-apache]/returns: change from notrun to 0 failed: cat "/tmp/bounce-apache-config.xml" | java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8081 create-job "bounce-apache" returned 255 instead of one of [0]
Notice: /Stage[main]/Ha_jenkins_sandbox/Jenkins::Job[bounce-apache]/Jenkins::Job::Present[bounce-apache]/Exec[jenkins enable-job bounce-apache]: Dependency Exec[jenkins create-job bounce-apache] has failures: true
Warning: /Stage[main]/Ha_jenkins_sandbox/Jenkins::Job[bounce-apache]/Jenkins::Job::Present[bounce-apache]/Exec[jenkins enable-job bounce-apache]: Skipping because of failed dependencies
cat "/tmp/bounce-apache-config.xml" | java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8081 create-job "bounce-apache"

When I run the above command it complains that the job already exists and exits with the 255 return code. If I delete the job and rerun this issue goes away but comes back for the next agent checkin. Looking at the jenkins::job file there seems to be an update-job but it is never called for me as the run fails after create is called.

Am I missing a step to avoid calling create-job on every job? A majority of the time all of my jobs will already exist so this seems pretty broken.

@rtyler rtyler added the bug Something isn't working label Sep 9, 2015
@rtyler rtyler added this to the 1.6.0 - Kato milestone Sep 9, 2015
@traviseret
Copy link
Author

After some more digging through the code, it looks like the source of my issue was the fact that the jobs directory in jenkins::jobs::present is hardcoded to point at /var/lib/jenkins/jobs. I was installing my jenkins instance to a different directory so the onlyif statement in the update-job call always failed. Moving my instance to /var/lib/jenkins resolved this, but forced me to install jenkins in a specific location. The ability to override the job_dir param would be useful.

@jhoblitt
Copy link
Member

jhoblitt commented Oct 2, 2015

@traviseret I have posted a PR that implements an alternative type for configuring jobs. #382 I wouldn't suggest trying it "in production" but it may be worth testing.

jhoblitt added a commit to jhoblitt/puppet-jenkins that referenced this issue Oct 11, 2015
* add `manager_user`, `user`, `manage_group`, `group` params to
  `jenkins` class.

* improve consistency of `file` resouce group ownership throughout
  the module

* add 'localstatedir' param to `jenkins` class and consistently use it
  to set the 'data' base dir throughout the module

* Deprecate/noop `username`, `group`, `create_user` params to
  `jenkins::plugin` define; replaced by `user`,`group`,etc. params to
  `jenkins` class

* Deprecate/noop `plugin_dir` param to `jenkins::plugin`; replaced by
  `localstatedir` param to `jenkins` class

closes voxpupuli#356 -- alternative approach
resolves voxpupuli#362
resolves voxpupuli#365
jhoblitt added a commit to jhoblitt/puppet-jenkins that referenced this issue Oct 12, 2015
* add `manager_user`, `user`, `manage_group`, `group` params to
  `jenkins` class.

* improve consistency of `file` resouce group ownership throughout
  the module

* add 'localstatedir' param to `jenkins` class and consistently use it
  to set the 'data' base dir throughout the module

* Deprecate/noop `username`, `group`, `create_user` params to
  `jenkins::plugin` define; replaced by `user`,`group`,etc. params to
  `jenkins` class

* Deprecate/noop `plugin_dir` param to `jenkins::plugin`; replaced by
  `localstatedir` param to `jenkins` class

closes voxpupuli#356 -- alternative approach
resolves voxpupuli#362
resolves voxpupuli#365
resolves voxpupuli#219
jhoblitt added a commit to jhoblitt/puppet-jenkins that referenced this issue Oct 12, 2015
* add `manager_user`, `user`, `manage_group`, `group` params to
  `jenkins` class.

* improve consistency of `file` resouce group ownership throughout
  the module

* add 'localstatedir' param to `jenkins` class and consistently use it
  to set the 'data' base dir throughout the module

* Deprecate/noop `username`, `group`, `create_user` params to
  `jenkins::plugin` define; replaced by `user`,`group`,etc. params to
  `jenkins` class

* Deprecate/noop `plugin_dir` param to `jenkins::plugin`; replaced by
  `localstatedir` param to `jenkins` class

closes voxpupuli#356 -- alternative approach
resolves voxpupuli#362
resolves voxpupuli#365
resolves voxpupuli#219
resolves voxpupuli#249
jhoblitt added a commit to jhoblitt/puppet-jenkins that referenced this issue Oct 12, 2015
* add `manager_user`, `user`, `manage_group`, `group` params to
  `jenkins` class.

* improve consistency of `file` resouce group ownership throughout
  the module

* add 'localstatedir' param to `jenkins` class and consistently use it
  to set the 'data' base dir throughout the module

* Deprecate/noop `username`, `group`, `create_user` params to
  `jenkins::plugin` define; replaced by `user`,`group`,etc. params to
  `jenkins` class

* Deprecate/noop `plugin_dir` param to `jenkins::plugin`; replaced by
  `localstatedir` param to `jenkins` class

closes voxpupuli#356 -- alternative approach
resolves voxpupuli#362
resolves voxpupuli#365
resolves voxpupuli#219
resolves voxpupuli#249
resolves voxpupuli#250
@ltutar
Copy link

ltutar commented Jan 6, 2016

I have version 1.6.1 of this module. I added the following to my yaml:
jenkins::localstatedir: '/opt/jenkins_data'
I get the error:

Info: /Stage[main]/Jenkins_config::Config/Jenkins::Credentials[admin]/Jenkins::Cli::Exec[create-jenkins-credentials-admin]/Exec[create-jenkins-credentials-admin]: Scheduling refresh of Class[Jenkins::Cli::Reload]
Info: Class[Jenkins::Cli::Reload]: Scheduling refresh of Exec[reload-jenkins]
Error: cat "/tmp/Seed_Job_Ben-config.xml" | java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8080 create-job "Seed_Job_Ben" returned 255 instead of one of [0]
Error: /Stage[main]/Jenkins_config::Config/Jenkins::Job[Seed_Job_Ben]/Jenkins::Job::Present[Seed_Job_Ben]/Exec[jenkins create-job Seed_Job_Ben]/returns: change from notrun to 0 failed: cat "/tmp/Seed_Job_Ben-config.xml" | java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8080 create-job "Seed_Job_Ben" returned 255 instead of one of [0]

The opt/jenkins_data is empty

/opt/jenkins_data
[root@jenkinsagent jenkins_data]# find .
.
./plugins
./jobs
[root@jenkinsagent jenkins_data]# 

and I see that /var/lib/jenkins is still used

[root@jenkinsagent jenkins_data]# cd /var/lib/jenkins
[root@jenkinsagent jenkins]# ls -al
total 68
drwxr-xr-x.  8 jenkins jenkins 4096 Jan  6 16:35 .
drwxr-xr-x. 19 root    root    4096 Jan  6 16:29 ..
-rw-r--r--.  1 jenkins jenkins  588 Jan  6 16:34 com.xebialabs.deployit.ci.DeployitNotifier.xml
-rw-r--r--.  1 jenkins jenkins  988 Jan  6 16:35 credentials.xml
-rw-r--r--.  1 jenkins jenkins    0 Jan  6 16:35 Download metadata.log
-rw-r--r--.  1 jenkins jenkins   21 Jan  6 16:20 Fingerprint cleanup.log
-rw-r--r--.  1 jenkins jenkins  159 Jan  6 16:35 hudson.model.UpdateCenter.xml
-rw-r--r--.  1 jenkins jenkins  371 Jan  6 15:47 hudson.plugins.git.GitTool.xml
-rw-------.  1 jenkins jenkins 1680 Jan  6 15:47 identity.key.enc
drwxr-xr-x.  4 jenkins jenkins 4096 Jan  6 15:47 jobs
-rw-r--r--.  1 jenkins jenkins  907 Jan  6 16:35 nodeMonitors.xml
drwxr-xr-x.  2 jenkins jenkins 4096 Jan  6 15:47 nodes
drwxr-xr-x. 26 jenkins jenkins 4096 Jan  6 16:35 plugins
-rw-r--r--.  1 jenkins jenkins  129 Jan  6 16:35 queue.xml.bak
-rw-r--r--.  1 jenkins jenkins   64 Jan  6 15:47 secret.key
-rw-r--r--.  1 jenkins jenkins    0 Jan  6 15:47 secret.key.not-so-secret
drwx------.  4 jenkins jenkins 4096 Jan  6 15:47 secrets
drwxr-xr-x.  2 jenkins jenkins 4096 Jan  6 15:47 updates
drwxr-xr-x.  2 jenkins jenkins 4096 Jan  6 15:47 userContent
[root@jenkinsagent jenkins]# 

I wonder what I am missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants