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

Support Jenkins #42

Closed
pragmaticivan opened this Issue Jun 5, 2016 · 21 comments

Comments

Projects
None yet
3 participants
@pragmaticivan

pragmaticivan commented Jun 5, 2016

Any idea about having Jenkins support?

@ArturT

This comment has been minimized.

Owner

ArturT commented Jun 6, 2016

Would be great to add that. I'm not familiar with Jenkins. Is it expose something like CI_NODE_TOTAL and CI_NODE_INDEX? Could you help with that, we need to add only new env in https://github.com/ArturT/knapsack/blob/master/lib/knapsack/config/env.rb

@pragmaticivan

This comment has been minimized.

pragmaticivan commented Jun 6, 2016

I'll simulate later using those Env vars first. Jenkins will be a little bit complex to configure because you can run everything in different nodes.

@pragmaticivan

This comment has been minimized.

pragmaticivan commented Jun 6, 2016

I'm also building my whole pipeline with Docker, so need to test that case too.

@ArturT

This comment has been minimized.

Owner

ArturT commented Jun 6, 2016

I'm wondering maybe you need to use a plugin like https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin but I don't know if it exposes job id and job total number which you could use as CI_NODE_INDEX and CI_NODE_TOTAL.

Please let me know if you will figure out something.

@pragmaticivan

This comment has been minimized.

pragmaticivan commented Jun 6, 2016

That's exactly the one I installed yesterday. I'm just wondering now the best way to share the workspace between multiple workflows like semaphore and circle ci do.
So we can have the same scenario

@pragmaticivan

This comment has been minimized.

pragmaticivan commented Jun 6, 2016

There's also this one (a brand new with DSL) that Jenkins created: https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin

But need to spend more time testing.

@mknapik

This comment has been minimized.

mknapik commented Jun 7, 2016

I think Jenkins Pipeline is a better approach since it's maintained actively by CloudBees and the community.
I can prepare example DSL configuration for the plugin if you want me to.

@ArturT

This comment has been minimized.

Owner

ArturT commented Jun 7, 2016

@mknapik It would be great if you could help!

@mknapik

This comment has been minimized.

mknapik commented Jun 8, 2016

I created example Ruby project with RSpec and Knapsack set up.
Here is Jenkins Pipeline configuration:
https://github.com/mknapik/jenkins-pipeline-knapsack/blob/master/Jenkinsfile

The relevant part is a function knapsack. The rest (e.g. RVM) is dependent on the setup of jenkins workers.
What should be our next step?

@ArturT

This comment has been minimized.

Owner

ArturT commented Jun 8, 2016

@mknapik Maybe you could create a pull request with updated README.md in knapsack gem and describe there how to set up Jenkins. You can add the link to your repository as the example project.

@pragmaticivan Could you check if that example works for your project?

@pragmaticivan

This comment has been minimized.

pragmaticivan commented Jun 8, 2016

I just performed this example and got an error.
screen shot 2016-06-08 at 9 34 43 am

In My case maybe because I didn't install RVM yet. And Also because I was planning to have Docker as container for that case.

@mknapik

This comment has been minimized.

mknapik commented Jun 9, 2016

If Ruby is present at your jenkins worker nodes I guess you could delete withRvm.
As I said, most of the stuff inside a closure is project/ci specific.
How about trying something like this:

parallel(
  knapsack(2) {
    unpack()
    try {
      docker.image("ruby:2.3.1").inside {
        bundle()
        sh 'bundle exec rake knapsack:rspec'
      }
    } finally {
      clearWorkspace()
    }
  }
)
@pragmaticivan

This comment has been minimized.

pragmaticivan commented Jun 9, 2016

@mknapik that started to work very well, how would you have a sidekick for Postgres using docker in this case? I think with this full example using docker would be a really nice case to explain also in a blog post.

@mknapik

This comment has been minimized.

mknapik commented Jun 10, 2016

Sure, I was actually thinking about writing about it. I'll let you know once I do.

@ArturT Regarding knapsack, is presenting knapsack groovy function with some short explanation in Knapsack README enough for you?
I think explaining Jenkins Pipeline thoroughly is probably out of scope of the project but I think giving the function should be enough for people who already know how to use JP. What do you think?

@ArturT

This comment has been minimized.

Owner

ArturT commented Jun 10, 2016

@mknapik Makes sense. You can add a link to Jenkins Pipeline docs where is described topic so it will be easy for someone using it for the first time to set up altogether.

@ArturT

This comment has been minimized.

Owner

ArturT commented Oct 7, 2016

@mknapik Would you be able to help prepare short tip how to run knapsack on Jenkins. You could add this to the section https://github.com/ArturT/knapsack#setup-your-ci-server
I'd appreciate that and then close this issue.

@mknapik

This comment has been minimized.

mknapik commented Oct 15, 2016

@ArturT It's still on my radar. I don't want to make empty promises but I'll try to commit something in the next 2 weeks.

@ArturT

This comment has been minimized.

Owner

ArturT commented Oct 15, 2016

@mknapik Would be awesome. Thanks!

@ArturT

This comment has been minimized.

Owner

ArturT commented Mar 24, 2017

I added info about Jenkins in readme and link to Jenkinsfile.

https://github.com/ArturT/knapsack#info-for-jenkins

@ArturT ArturT closed this Mar 24, 2017

@mknapik

This comment has been minimized.

mknapik commented Jun 27, 2017

@ArturT Duke Nukem Forever of blog posts: http://blog.knapik.me/knapsack-with-jenkins-pipeline/
Sorry for the delay and I hope you will find it useful!

@ArturT

This comment has been minimized.

Owner

ArturT commented Jun 27, 2017

@mknapik Awesome work! I've added the article to the readme: https://github.com/ArturT/knapsack#info-for-jenkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment