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

List the enabled jobs on Artifactory #385

Open
mouliveera opened this issue Jun 21, 2021 · 10 comments
Open

List the enabled jobs on Artifactory #385

mouliveera opened this issue Jun 21, 2021 · 10 comments

Comments

@mouliveera
Copy link

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.
@DavidRadoorHummel
Copy link

DavidRadoorHummel commented Jun 23, 2021

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.

@mouliveera
Copy link
Author

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

@DavidRadoorHummel
Copy link

DavidRadoorHummel commented Jun 23, 2021

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.

@devopsdayz
Copy link

devopsdayz commented Jun 23, 2021

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

@DavidRadoorHummel
Copy link

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

@myedla1-reputation
Copy link

myedla1-reputation commented Jun 25, 2021

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
====================

@DavidRadoorHummel
Copy link

DavidRadoorHummel commented Jun 25, 2021

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

@myedla1-reputation
Copy link

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

@myedla1-reputation
Copy link

Hi David,

Please share the ticket details once created.

Thanks & Regards,
Madhu

@DavidRadoorHummel
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants