athieriot/drone-artifactory

Examples of using the plugin

JoeTalbot opened this issue · 15 comments

I am fairly new to drone, and i am struggling with using this plugin, either i can get drone to run successfully but completely skip anything related to the artifactory plugin, or it gives me an obscure error.

For example, if my entire .drone.yml looks like this:

pipeline:
  artifactory:
    image: athieriot/drone-artifactory
    url: [url]
    username: $$USERNAME
    password: $$PASSWORD
    pom: pom.xml
    repo_key: [repo_key]
    files:
      - target/*.jar
      - target/*.war
      - dist/**/*.min.js

the output of the drone run is:

username@80e6500b67fa:MobileAPI-- (joe_artifactory)$ drone exec
Running Matrix job #0

if i have my entire .drone.yml file looking like this:

pipeline:
  test:
    image: maven:alpine
    commands:
     - mvn --quiet --batch-mode test
     
  publish_war:
    image: maven:alpine
    commands:
      - mvn --batch-mode clean install
  deploy_war:
    plugin:
      artifactory:
        image: athieriot/drone-artifactory
        url: [url]
        username: $$USERNAME
        password: $$PASSWORD
        pom: pom.xml
        force_upload: true
        repo_key: [repo_key]
        files:
          - /root/.m2/repository/com/company/DEV/something-services/1/somehting-services-1.war

then everything prior to the deploy_war step runs successfully. What am I missing?

Hi @JoeTalbot,

First of all, please note that this plugin only supports Drone 0.5 since yesterday so there might still be some mix and match in the documentation between the two config set.

Because you use the pipeline keyword, I'm assuming you are using Drone 0.5, but it seems that you have used Drone 0.4 configuration for drone-artifactory.

At first glance, there is two things I can see that are incorrect:

  • You can remove the "plugin:" line under "deploy_war", it is not necessary anymore since pipeline has been introduced.
  • Secrets are not injected using $$ anymore. I advice you to take a look at this page: https://github.com/athieriot/drone-artifactory/blob/master/DOCS.md which explains how to register secrets with Drone 0.5 and if you do so, you'll be able to remove both "username" and "password"

Please keep us updated on how it goes :)
It might help other people.

@athieriot Thank you for the quick response, i tried that out, and it is still not running anything to do with the plugin? I am running drone 5, and here is my updated drone.yml file.

pipeline:
  test:
    image: maven:alpine
    commands:
     - mvn --quiet --batch-mode test
  publish_war:
    image: maven:alpine
    commands:
      - mvn --batch-mode clean install
    artifactory:
      image: athieriot/drone-artifactory
      url: [url]
      pom: pom.xml
      force_upload: true
      repo_key: [repo_key]
      files:
          - /root/.m2/repository/com/tgt/DEV/maximo-services/1/maximo-services-1.war

I get an error:

[publish_war:L4:1s] [INFO] ------------------------------------------------------------------------
[publish_war:L5:1s] [INFO] BUILD FAILURE
[publish_war:L6:1s] [INFO] ------------------------------------------------------------------------
[publish_war:L7:1s] [INFO] Total time: 0.853 s
[publish_war:L8:1s] [INFO] Finished at: 2016-11-22T16:32:42+00:00
[publish_war:L9:1s] [INFO] Final Memory: 12M/106M
[publish_war:L10:1s] [INFO] ------------------------------------------------------------------------
[publish_war:L11:1s] [ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[publish_war:L12:1s] [ERROR]
[publish_war:L13:1s] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[publish_war:L14:1s] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[publish_war:L15:1s] [ERROR]
[publish_war:L16:1s] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[publish_war:L17:1s] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

And if I remove the artifactory plugin information it builds and works just fine, but it doesn't get deployed.

Maybe I am missing something completely, but how does the plugin have access to the war file built in the publish_war step? is that how this is intended to be used, or am i setting something up wrong? Essentially the command mvn clean install generates the file i want, and i know where that is put on the maven:apline image i am using, so does this plugin allow me to push that file directly to artifactory?

Ah. My bad.
You can get read of the "artifactory:" line as well.

This name use to have a meaning (Pointing out the Docker image to use) but not anymore.

Also, to answer your question, plugins normally share the workspace, so anything built during the previous phases will be accessible later (From the current directory).
Meaning you should probably update the "files" value to be relative. Something like:

  target/maximo-services-1.war

Replacing by the actual name obviously

I updated my drone.yml file to:

pipeline:
  test:
    image: maven:alpine
    commands:
     - mvn --quiet --batch-mode test
  publish_war:
    image: maven:alpine
    commands:
      - mvn --batch-mode clean install
  deploy_war:
    url: [url]
    pom: pom.xml
    force_upload: true
    repo_key: [repo_key]
    files:
        - target/something-services-1.war

And it still completes successfully at the publish_war step but does not continue to deploy_war. The confusing part is that I get no errors, and it's hard to start to troubleshoot?

You still need the image name though (In deploy_war section)

image: athieriot/drone-artifactory

I'll soon be dry of answers and yes, the lack of error message seems problematic but I have good hopes ;)
(Sure you don't have any logs server side?)

It starting to look good though, you must be close.

I really appreciate the assistance! I found something that might shed more light. running drone exec returns no errors, but checking in my code to git and letting it run off a PR returns:

info: Project groupId: com.company.DEV
0s
2
info: Project artifactId: maximo-services
0s
3
info: Project version: 1
0s
4
info: Uploading /drone/src/github.com/repo/MobileAPI/pom.xml as maximo-services-1.pom into infra-automation-dev/test
0s
5
error: An error happened while trying to publish the file /drone/src/github.com/repo/MobileAPI/pom.xml: HTTP Status Code from server was: 403

I am getting closer, i found someone to help me get the logs off the artifactory server. using this drone.yml:


pipeline:
  test:
    image: maven:alpine
    commands:
     - mvn --quiet --batch-mode test
  publish_war:
    image: maven:alpine
    commands:
      - mvn --batch-mode clean install
  deploy_war:
    image: athieriot/drone-artifactory
    url: [url]
    pom: pom.xml
    force_upload: true
    repo_key: [repo_key]
    files:
        - target/maximo-services-1.war

I get this output in the server logs:

2016-11-22 17:00:34,379 [ajp-nio-8009-exec-183] [WARN ] (o.a.w.s.RequestUtils:155) - Request /artifactory/repository/test/com/company/DEV/some-services/1/some-services-1.pom should be a repo request and does not match any repo key
2016-11-22 17:21:37,075 [ajp-nio-8009-exec-177] [WARN ] (o.a.w.s.RequestUtils:155) - Request /artifactory/repository/test/com/company/DEV/some-services/1/some-services-1.pom should be a repo request and does not match any repo key
2016-11-22 17:36:05,249 [ajp-nio-8009-exec-157] [WARN ] (o.a.w.s.RequestUtils:155) - Request /artifactory/repository/test/com/company/DEV/some-services/1/some-services-1.pom should be a repo request and does not match any repo key

im not sure how its determining the repo key, but does something with the settings look goofy?

I am unable to get this to work, I'm going to switch to using a maven artifactory plugin and deploy with maven instead. Thank you for the quick response and offering assistance.

I was able to get this working with a slightly different image for the artifactory plugin section. https://hub.docker.com/r/jmccann/drone-artifactory, and added the latest tag. Also, i had to ensure the repo i was pushing to was actually a maven repo, and I was able to deploy

That's good news.

Funny thing is that @jmccann pushed these changes into my repository a few days ago.
So theoretically you should have been ok with your previous configuration.

I think the main problem is I wasn't using the latest tag with your image, i intend to try that today and see if it works.

There is no other tag though but I did push several times before merging the code.

It might still be a genuine issue.

Thank you for taking the time

Not a problem. I will check it out and see what happens!

I was able to get it to work, i think it was a combination of my understanding, and making sure i had the correct drone secrets in place. Here is the final working drone.yml.


pipeline:
  test:
    image: maven:alpine
    commands:
     - mvn --quiet --batch-mode test
  build_war:
    image: maven:alpine
    commands:
      - mvn --batch-mode clean install
  deploy_war:
    image: athieriot/drone-artifactory:latest
    url: [url]
    pom: pom.xml
    repo_key: [repo_key]
    files:
      - target/*.jar
      - target/*.war
      - dist/**/*.min.js
    when:
      branch: master

This is absolutely delightful to here !

I'm glad it looks good now.

Is there anything that can be made clearer in the documentation?
Something in particular that you didn't quite get we can so we can update
the document for the next guys?

Thank you.

On 23 November 2016 at 16:36, Joe Talbot notifications@github.com wrote:

I was able to get it to work, i think it was a combination of my
understanding, and making sure i had the correct drone secrets in place.
Here is the final working drone.yml.

pipeline:
test:
image: maven:alpine
commands:
- mvn --quiet --batch-mode test
build_war:
image: maven:alpine
commands:
- mvn --batch-mode clean install
deploy_war:
image: athieriot/drone-artifactory:latest
url: https://binrepo.target.com
pom: pom.xml
repo_key: infra-automation-dev
files:
- target/.jar
- target/
.war
- dist/*/.min.js
when:
branch: master


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAoZjRZkh92Z3cV_YACUbHC5WQK6soq6ks5rBGupgaJpZM4K5nGL
.