artifactory-user-plugins icon indicating copy to clipboard operation
artifactory-user-plugins copied to clipboard

List the enabled jobs on Artifactory

Open mouliveera opened this issue 4 years ago • 10 comments

We are using artifactory cleanup jobs https://github.com/jfrog/artifactory-user-plugins/tree/master/cleanup/artifactCleanup in our enviroment.

As per the readme page, we have tried these commands to enable the cleanup jobs

curl -X POST -v -u admin:password "http://localhost:8080/artifactory/api/plugins/execute/cleanup?params=months=1;repos=libs-release-local;dryRun=true;paceTimeMS=2000;disablePropertiesSupport=true"

Question is:

  • How can we list the cleanup and jobs? Tried crontab -lu artifactory, but no luck.

mouliveera avatar Jun 21 '21 09:06 mouliveera

The cURL command only runs the plugin once, with the specified parameters. To make it run periodically you have to populate the accompanying artifactCleanup.json file with the cron schedule, in addition to all the other settings.

DavidRadoorHummel avatar Jun 23 '21 07:06 DavidRadoorHummel

Yes, we are using the same JSON that was provided on the plugin page. located at /etc/artifactory/plugins

{
    "policies": [
        {
            "cron": "0 0 1 ? * 1",
            "repos": [
                "libs-release-local"
            ],
            "timeUnit": "day",
            "timeInterval": 3,
            "dryRun": true,
            "paceTimeMS": 500,
            "disablePropertiesSupport": true
        }
    ]
}

Questions:

  • How can we pass the JSON file with cURL
  • How to check whether the JSO file is in use for the scheduled jobs.

We tried to reload after adjusting the JSON file in the plugin directory, but no luck. it is not reflecting in the artifactory UI page[Services -> Articatory -> Maintenance].

artifactory@artifactory-0:/opt/jfrog/artifactory$ curl -X POST -u admin:password "http://localhost:8082/artifactory/api/plugins/reload"

Successfully loaded:  artifactCleanup.groovy, cleanupDebian.groovy

mouliveera avatar Jun 23 '21 12:06 mouliveera

I don't know how to pass a JSON file to a cURL command, though I don't understand why you would. If you want to run on more than one repo, you simply separate repo names with commas, ie:

curl -X POST -v -u admin:password "http://localhost:8080/artifactory/api/plugins/execute/cleanup?params=months=1;repos=libs-release-local,repo2,repo3,repo4;dryRun=true;paceTimeMS=2000;disablePropertiesSupport=true"

The cURL command is usually just for testing that your plugin works.

How to check whether the JSON file is in use for the scheduled jobs.

To my knowledge you can't.

It seems like you are missing some general knowledge about how the plugins actually work, I highly recommend reading through this page: https://www.jfrog.com/confluence/display/JFROG/User+Plugins

In the plugin you are talking about, there are 2 functions:

  • executions
  • jobs

The executions is the code you execute when you call the cURL command. jobs is where the cron job is created. And from the looks of your artifactCleanup.json file, you only run the plugin on libs-release-local at 01:00 AM on mondays.

If you want to see if a plugin is executing, I'd recommend having a look at the artifactory log.

Also you need to make sure you've added your plugin to the list of loggers. How to do that is explained in the link i provided:

Controlling Plugin Log Level

The default log level for user plugins is "warn". To change a plugin log level, add the following to $JFROG_HOME/artifactory/var/etc/artifactory/logback.xml:

 <logger name="my-plugin">
     <level value="info"/>
 </logger>
 

The logger name is the name of the plugin file without the ".groovy" extension (in the example above the plugin file name is my-plugin.groovy). The logging levels can be either error, warn, info, debug or trace.

DavidRadoorHummel avatar Jun 23 '21 13:06 DavidRadoorHummel

Thanks David for sharing the information.

Enabled the logger name in "/opt/jfrog/artifactory/var/etc/artifactory/logback.xml" and executed the curl command to ran the artifactsCleanup plugin. Curl command is executing successfully, but not sure whether it’s really doing any cleanup as there are no cleanup results in the output.

And nothing is written to the cleanup log file.

-rw-r----- 1 0 Jun 22 15:50 artifactory-cleanup.log

====================== $ curl -X POST -v -u admin:password "http://localhost:8082/artifactory/api/plugins/execute/cleanup?params=timeUnit=month;timeInterval=1;repos=libs-release-local;dryRun=true;paceTimeMS=2000;disablePropertiesSupport=true"

Trying 127.0.0.1:8082... Connected to localhost (127.0.0.1) port 8082 (#0) Server auth using Basic with user 'admin' POST /artifactory/api/plugins/execute/cleanup?params=timeUnit=month;timeInterval=1;repos=libs-release-local;dryRun=true;paceTimeMS=2000;disablePropertiesSupport=true HTTP/1.1 Host: localhost:8082 Authorization: Basic xxxxxxxxxxxxx User-Agent: curl/7.74.0 Accept: /

Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Content-Length: 0 Connection #0 to host localhost left intact

Maddu avatar Jun 23 '21 18:06 Maddu

You should look in artifactory-service.log for outputs from plugins. Also, writing the logger name in logback.xml is not sufficient, you need to specify a level as well ( info for example).

I hope this helps

DavidRadoorHummel avatar Jun 24 '21 09:06 DavidRadoorHummel

Hi David,

Yes, we have enabled the logger and specified the level to "info" as mentioned below,

<logger name="artifactCleanup" level="info"/>

I can see only this information in the artifactory-service.log, after running the above mentioned curl command for running the cleanup plugin.

========================== 2021-06-25T09:00:27.941Z [jfrt ] [INFO ] [6e717cba6e9f053f] [a.e.EventsLogCleanUpService:69] [art-exec-1 ] - Starting cleanup of old events from event log
2021-06-25T09:00:32.644Z [jfrt ] [INFO ] [6e717cba6e9f053f] [.e.EventsLogCleanUpService:100] [art-exec-1 ] - Cleanup of old events from event log finished
2021-06-25T09:59:50.385Z [jfrt ] [INFO ] [49a51a47e4f692d6] [aseBundleCleanupServiceImpl:84] [art-exec-5 ] - Starting to cleanup incomplete Release Bundles
2021-06-25T09:59:50.404Z [jfrt ] [INFO ] [49a51a47e4f692d6] [aseBundleCleanupServiceImpl:90] [art-exec-5 ] - Finished incomplete Release Bundles cleanup
2021-06-25T10:48:16.556Z [jfrt ] [INFO ] [36e8ebacb2d9e1eb] [ager$LogbackConfigWatchDog:147] [logback-watchdog ] - Reloaded logback config from: /opt/jfrog/artifactory/var/etc/artifactory/logback.xml.
2021-06-25T10:50:54.393Z [jfrt ] [INFO ] [754f8c87874506df] [o.a.a.p.PluginsAddonImpl:121 ] [http-nio-8081-exec-8] - Reloading plugins
2021-06-25T10:57:38.954Z [jfrt ] [INFO ] [ ] [ffectedConfigStreamObserver:32] [Stream_1624611588307] - publishing full invalidation and attempting to resubscribe to affected configuration changes
2021-06-25T10:57:39.563Z [jfrt ] [INFO ] [ ] [ffectedConfigStreamObserver:32] [Stream_1624611589563] - publishing full invalidation and attempting to resubscribe to affected configuration changes
2021-06-25T10:57:39.765Z [jfrt ] [INFO ] [ ] [ffectedConfigStreamObserver:32] [Stream_1624611589555] - publishing full invalidation and attempting to resubscribe to affected configuration changes
2021-06-25T10:57:41.758Z [jfrt ] [INFO ] [ ] [ffectedConfigStreamObserver:32] [Stream_1624611596743] - publishing full invalidation and attempting to resubscribe to affected configuration changes
2021-06-25T10:59:08.355Z [jfrt ] [INFO ] [ ] [ffectedConfigStreamObserver:32] [Stream_1624611588307] - publishing full invalidation and attempting to resubscribe to affected configuration changes
2021-06-25T10:59:50.386Z [jfrt ] [INFO ] [9e98497d5e8e7824] [aseBundleCleanupServiceImpl:84] [art-exec-1 ] - Starting to cleanup incomplete Release Bundles
2021-06-25T10:59:50.389Z [jfrt ] [INFO ] [9e98497d5e8e7824] [aseBundleCleanupServiceImpl:90] [art-exec-1 ] - Finished incomplete Release Bundles cleanup
====================

myedla1-reputation avatar Jun 25 '21 11:06 myedla1-reputation

That is odd. In any event, it looks like the plugin is not running at all. Do you have other plugins that work? If not, then this may be a more general issue and not related specifically to this plugin.

~~Did you remember to reload the plugins? If i recall correctly, automatically reloading plugins is not enabled by default. Simply placing the plugins in the correct folder, does not mean that artifactory loads them.~~

~~You can manually reload the plugins through the REST API: https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-ReloadPlugins~~

I just saw in your output that it does say "reloading plugins". I'm sorry I have no further ideas to what could be wrong. I would make a ticket to JFrog support

DavidRadoorHummel avatar Jun 25 '21 12:06 DavidRadoorHummel

Yes, reloaded the plugin using REST API. curl -v -u admin:xxxxx -X POST http://localhost:8082/artifactory/api/plugins/reload

myedla1-reputation avatar Jun 25 '21 12:06 myedla1-reputation

Hi David,

Please share the ticket details once created.

Thanks & Regards, Madhu

myedla1-reputation avatar Jun 25 '21 13:06 myedla1-reputation

Ticket details? I don't work for JFrog. You have to make the ticket yourself. I was just trying to help

DavidRadoorHummel avatar Jun 28 '21 06:06 DavidRadoorHummel