gvalkov/jenkins-autojobs

Cleanup only jobs that match naming pattern !

Closed this issue · 5 comments

Hi,

Thank you very much for this program !
However I feel like I want it to delete jobs that only match the naming pattern, and not other jobs.

I have multiple jobs like
PROJECT-ADMIN-templatelatest
PROJECT-BRANCH-mybranch

I have two auto-jenkins jobs and runnig them sequentially, the last run will delete jobs created by the first run.

Thank you very much !

Logs from running one of my template

s.erard@PAR-DEV-JENKINS-SLAVE:/home/jenkins/autojobs$ jenkins-makejobs-git FRONT-SEARCH-BRANCH
loading config from "/home/jenkins/autojobs/FRONT-SEARCH-BRANCH"

explicitly ignored:
 - refs/tags/latest
 - refs/tags/release/ed
 - refs/tags/v1.0.0
 - refs/tags/v1.0.1
 - refs/tags/v1.0.10
 - refs/tags/v1.0.11
 - refs/tags/v1.0.12
 - refs/tags/v1.0.13
 - refs/tags/v1.0.14
 - refs/tags/v1.0.15
 - refs/tags/v1.0.16
 - refs/tags/v1.0.17
 - refs/tags/v1.0.18
 - refs/tags/v1.0.19
 - refs/tags/v1.0.2
 - refs/tags/v1.0.20
 - refs/tags/v1.0.21
 - refs/tags/v1.0.22
 - refs/tags/v1.0.3
 - refs/tags/v1.0.4
 - refs/tags/v1.0.5
 - refs/tags/v1.0.6
 - refs/tags/v1.0.7
 - refs/tags/v1.0.8
 - refs/tags/v1.0.9
 - refs/tags/v1.1.0
 - refs/tags/v1.1.1
 - refs/tags/v1.1.2
 - refs/tags/v1.1.3
 - refs/tags/v1.1.4
 - refs/tags/v1.2.0
 - refs/tags/v1.2.1
 - refs/tags/v1.2.2
 - refs/tags/v1.2.3
 - refs/tags/v1.2.4
 - refs/tags/v1.2.5
 - refs/tags/v1.2.6

processing ref: refs/heads/develop
. job name: FRONT-SEARCH-BRANCH-develop
. job exists: True
. job updated

processing ref: refs/heads/events/ouishare
. job name: FRONT-SEARCH-BRANCH-events-ouishare
. job exists: True
. job updated

processing ref: refs/heads/feature-mobile-app
. job name: FRONT-SEARCH-BRANCH-feature-mobile-app
. job exists: True
. job updated

processing ref: refs/heads/feature/apps-button
. job name: FRONT-SEARCH-BRANCH-feature-apps-button
. job exists: True
. job updated

processing ref: refs/heads/feature/ci
. job name: FRONT-SEARCH-BRANCH-feature-ci
. job exists: True
. job updated

processing ref: refs/heads/feature/core_npm
. job name: FRONT-SEARCH-BRANCH-feature-core_npm
. job exists: True
. job updated

processing ref: refs/heads/feature/favorites
. job name: FRONT-SEARCH-BRANCH-feature-favorites
. job exists: True
. job updated

processing ref: refs/heads/feature/favorites-from-serp
. job name: FRONT-SEARCH-BRANCH-feature-favorites-from-serp
. job exists: True
. job updated

processing ref: refs/heads/feature/grunt_auto_sprite
. job name: FRONT-SEARCH-BRANCH-feature-grunt_auto_sprite
. job exists: True
. job updated

processing ref: refs/heads/feature/integration_ia
. job name: FRONT-SEARCH-BRANCH-feature-integration_ia
. job exists: True
. job updated

processing ref: refs/heads/master
. job name: FRONT-SEARCH-BRANCH-master
. job exists: True
. job updated

processing ref: refs/heads/tralala_v2
. job name: FRONT-SEARCH-BRANCH-tralala_v2
. job exists: True
. job updated

cleaning up old jobs:
 - FRONT-SEARCH-BRANCH-feature-connect
 - FRONT-SEARCH-BRANCH-feature-ed_setup
 - FRONT-SEARCH-BRANCH-feature-preliveinit
 - FRONT-SEARCH-BRANCH-feature-sso
 - FRONT-SEARCH-BRANCH-latest
 - FRONT-SEARCH-BRANCH-rc
 - FRONT-SEARCH-BRANCH-release-ed
 - FRONT-SEARCH-BRANCH-v1.0.0
 - FRONT-SEARCH-BRANCH-v1.0.1
 - FRONT-SEARCH-BRANCH-v1.0.10
 - FRONT-SEARCH-BRANCH-v1.0.11
 - FRONT-SEARCH-BRANCH-v1.0.12
 - FRONT-SEARCH-BRANCH-v1.0.13
 - FRONT-SEARCH-BRANCH-v1.0.14
 - FRONT-SEARCH-BRANCH-v1.0.15
 - FRONT-SEARCH-BRANCH-v1.0.16
 - FRONT-SEARCH-BRANCH-v1.0.17
 - FRONT-SEARCH-BRANCH-v1.0.18
 - FRONT-SEARCH-BRANCH-v1.0.19
 - FRONT-SEARCH-BRANCH-v1.0.2
 - FRONT-SEARCH-BRANCH-v1.0.20
 - FRONT-SEARCH-BRANCH-v1.0.21
 - FRONT-SEARCH-BRANCH-v1.0.22
 - FRONT-SEARCH-BRANCH-v1.0.3
 - FRONT-SEARCH-BRANCH-v1.0.4
 - FRONT-SEARCH-BRANCH-v1.0.5
 - FRONT-SEARCH-BRANCH-v1.0.6
 - FRONT-SEARCH-BRANCH-v1.0.7
 - FRONT-SEARCH-BRANCH-v1.0.8
 - FRONT-SEARCH-BRANCH-v1.0.9
 - FRONT-SEARCH-BRANCH-v1.1.0
 - FRONT-SEARCH-BRANCH-v1.1.1
 - FRONT-SEARCH-BRANCH-v1.1.2
 - FRONT-SEARCH-BRANCH-v1.1.3
 - FRONT-SEARCH-BRANCH-v1.1.4
 - FRONT-SEARCH-BRANCH-v1.2.0
 - FRONT-SEARCH-BRANCH-v1.2.1
 - FRONT-SEARCH-BRANCH-v1.2.2
 - FRONT-SEARCH-BRANCH-v1.2.3
 - FRONT-SEARCH-BRANCH-v1.2.4
 - FRONT-SEARCH-BRANCH-v1.2.5
 - FRONT-SEARCH-BRANCH-v1.2.6
 - FRONT-SEARCH-LATEST-develop
 - FRONT-SEARCH-LATEST-events-ouishare
 - FRONT-SEARCH-LATEST-feature-apps-button
 - FRONT-SEARCH-LATEST-feature-ci
 - FRONT-SEARCH-LATEST-feature-connect
 - FRONT-SEARCH-LATEST-feature-core_npm
 - FRONT-SEARCH-LATEST-feature-ed_setup
 - FRONT-SEARCH-LATEST-feature-favorites
 - FRONT-SEARCH-LATEST-feature-favorites-from-serp
 - FRONT-SEARCH-LATEST-feature-grunt_auto_sprite
 - FRONT-SEARCH-LATEST-feature-integration_ia
 - FRONT-SEARCH-LATEST-feature-mobile-app
 - FRONT-SEARCH-LATEST-feature-preliveinit
 - FRONT-SEARCH-LATEST-feature-sso
 - FRONT-SEARCH-LATEST-latest
 - FRONT-SEARCH-LATEST-master
 - FRONT-SEARCH-LATEST-tralala_v2
 - FRONT-SEARCH-LATEST-rc
 - FRONT-SEARCH-LATEST-release-ed
 - FRONT-SEARCH-LATEST-v1.0.0
 - FRONT-SEARCH-LATEST-v1.0.1
 - FRONT-SEARCH-LATEST-v1.0.10
 - FRONT-SEARCH-LATEST-v1.0.11
 - FRONT-SEARCH-LATEST-v1.0.12
 - FRONT-SEARCH-LATEST-v1.0.13
 - FRONT-SEARCH-LATEST-v1.0.14
 - FRONT-SEARCH-LATEST-v1.0.15
 - FRONT-SEARCH-LATEST-v1.0.16
 - FRONT-SEARCH-LATEST-v1.0.17
 - FRONT-SEARCH-LATEST-v1.0.18
 - FRONT-SEARCH-LATEST-v1.0.19
 - FRONT-SEARCH-LATEST-v1.0.2
 - FRONT-SEARCH-LATEST-v1.0.20
 - FRONT-SEARCH-LATEST-v1.0.21
 - FRONT-SEARCH-LATEST-v1.0.22
 - FRONT-SEARCH-LATEST-v1.0.3
 - FRONT-SEARCH-LATEST-v1.0.4
 - FRONT-SEARCH-LATEST-v1.0.5
 - FRONT-SEARCH-LATEST-v1.0.6
 - FRONT-SEARCH-LATEST-v1.0.7
 - FRONT-SEARCH-LATEST-v1.0.8
 - FRONT-SEARCH-LATEST-v1.0.9
 - FRONT-SEARCH-LATEST-v1.1.0
 - FRONT-SEARCH-LATEST-v1.1.1
 - FRONT-SEARCH-LATEST-v1.1.2
 - FRONT-SEARCH-LATEST-v1.1.3
 - FRONT-SEARCH-LATEST-v1.1.4
 - FRONT-SEARCH-LATEST-v1.2.0
 - FRONT-SEARCH-LATEST-v1.2.1
 - FRONT-SEARCH-LATEST-v1.2.2
 - FRONT-SEARCH-LATEST-v1.2.3
 - FRONT-SEARCH-LATEST-v1.2.4
 - FRONT-SEARCH-LATEST-v1.2.5
 - FRONT-SEARCH-LATEST-v1.2.6
 - FRONT-SEARCH-PACKAGE-develop
 - FRONT-SEARCH-PACKAGE-events-ouishare
 - FRONT-SEARCH-PACKAGE-feature-apps-button
 - FRONT-SEARCH-PACKAGE-feature-ci
 - FRONT-SEARCH-PACKAGE-feature-connect
 - FRONT-SEARCH-PACKAGE-feature-core_npm
 - FRONT-SEARCH-PACKAGE-feature-ed_setup
 - FRONT-SEARCH-PACKAGE-feature-favorites
 - FRONT-SEARCH-PACKAGE-feature-favorites-from-serp
 - FRONT-SEARCH-PACKAGE-feature-grunt_auto_sprite
 - FRONT-SEARCH-PACKAGE-feature-integration_ia
 - FRONT-SEARCH-PACKAGE-feature-mobile-app
 - FRONT-SEARCH-PACKAGE-feature-preliveinit
 - FRONT-SEARCH-PACKAGE-feature-sso
 - FRONT-SEARCH-PACKAGE-latest
 - FRONT-SEARCH-PACKAGE-master
 - FRONT-SEARCH-PACKAGE-tralala_v2
 - FRONT-SEARCH-PACKAGE-rc
 - FRONT-SEARCH-PACKAGE-release-ed
 - FRONT-SEARCH-PACKAGE-v1.0.0
 - FRONT-SEARCH-PACKAGE-v1.0.1
 - FRONT-SEARCH-PACKAGE-v1.0.10
 - FRONT-SEARCH-PACKAGE-v1.0.11
 - FRONT-SEARCH-PACKAGE-v1.0.12
 - FRONT-SEARCH-PACKAGE-v1.0.13
 - FRONT-SEARCH-PACKAGE-v1.0.14
 - FRONT-SEARCH-PACKAGE-v1.0.15
 - FRONT-SEARCH-PACKAGE-v1.0.16
 - FRONT-SEARCH-PACKAGE-v1.0.17
 - FRONT-SEARCH-PACKAGE-v1.0.18
 - FRONT-SEARCH-PACKAGE-v1.0.19
 - FRONT-SEARCH-PACKAGE-v1.0.2
 - FRONT-SEARCH-PACKAGE-v1.0.20
 - FRONT-SEARCH-PACKAGE-v1.0.21
 - FRONT-SEARCH-PACKAGE-v1.0.22
 - FRONT-SEARCH-PACKAGE-v1.0.3
 - FRONT-SEARCH-PACKAGE-v1.0.4
 - FRONT-SEARCH-PACKAGE-v1.0.5
 - FRONT-SEARCH-PACKAGE-v1.0.6
 - FRONT-SEARCH-PACKAGE-v1.0.7
 - FRONT-SEARCH-PACKAGE-v1.0.8
 - FRONT-SEARCH-PACKAGE-v1.0.9
 - FRONT-SEARCH-PACKAGE-v1.1.0
 - FRONT-SEARCH-PACKAGE-v1.1.1
 - FRONT-SEARCH-PACKAGE-v1.1.2
 - FRONT-SEARCH-PACKAGE-v1.1.3
 - FRONT-SEARCH-PACKAGE-v1.1.4
 - FRONT-SEARCH-PACKAGE-v1.2.0
 - FRONT-SEARCH-PACKAGE-v1.2.1
 - FRONT-SEARCH-PACKAGE-v1.2.2
 - FRONT-SEARCH-PACKAGE-v1.2.3
 - FRONT-SEARCH-PACKAGE-v1.2.4
 - FRONT-SEARCH-PACKAGE-v1.2.5
 - FRONT-SEARCH-PACKAGE-v1.2.6

I don't want this to delete FRONT-SEARCH-LATEST-* nor FRONT-SEARCH-PACKAGE-*

I'd like to be able to configure cleanup: name_pattern_match then in the cleanup def, check for the iterated job to check if its name matches the pattern to grant deletion.

I finally came to understand what «tag» was standing for : this is not ref tag in SCM vocable but tags applied to jenkins jobs.

Thank you very much !!

Happy to hear that things worked out and that jenkins-autojobs is of use to you.

Just fiy, there is currently an annoying issue with the current cleanup/tagging functionality (#28) that will make Jenkins warn you about unreadable data (e.g. You have data stored in an older format and/or unreadable data.).

I recommend renaming "tag" to "flag". Especially on Subversion and Git, people tend to interprete "Tag" as a certain point in time of code history.