Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
SurgicalOntologist
Jun 17, 2004

Anyone use crossplane in production? I'm putting together a POC and think it's pretty cool but also kind of finicky.

Adbot
ADBOT LOVES YOU

freeasinbeer
Mar 26, 2015

by Fluffdaddy

SurgicalOntologist posted:

Anyone use crossplane in production? I'm putting together a POC and think it's pretty cool but also kind of finicky.

Too many CRDs cause API issues, like installing the AWS provider noticeably slows it down.

Junkiebev
Jan 18, 2002


Feel the progress.

Lady Radia posted:

it's super frustrating that k8s lives up to the hype for the most part lol, i wish it were worse to work with and that rancher just didnt work half the time so i could argue against it.

Yea both k8s and rancher are Dope

Hadlock
Nov 9, 2004

So a guy at work deployed serverless pypi server using a bunch of GitHub stuff and UI controls

Working with GitHub feels more and more like working with Salesforce or servicenow. We are slowly being absorbed into the Borg

At first I was like, "is this hypercard?" but now it just feels like I'm a Salesforce admin

Time to go grind leetcode

Gyshall
Feb 24, 2009

Had a couple of drinks.
Saw a couple of things.
Where are the best DevOps job boards in tyool 2022?

LochNessMonster
Feb 3, 2005

I need about three fitty


Gyshall posted:

Where are the best DevOps job boards in tyool 2022?

LinkedIn by a landslide.

Super-NintendoUser
Jan 16, 2004

COWABUNGERDER COMPADRES
Soiled Meat

Gyshall posted:

Where are the best DevOps job boards in tyool 2022?

I literally just set my profile to "looking for a job" or whatever and with in days I had like seven Devops interviews with real companies (not even recruiter spam, but like internal HR interviews).

sausage king of Chicago
Jun 13, 2001
Just started using Jenkins at my job. I'm having an issue where I have a Version.json file that looks something like this:
code:
 {
“Major”: 0,
“Minor”: 1
} 
In my Jenkinsfile, I have a stage in my pipeline where I call a bash script that updates the version like:
code:
 {
“Major”: 0,
“Minor”: 2
} 
That works great. My issue is that after the version update happens, I need to commit this Version.json file into source control. So, I have in my bash script something like:
code:
git checkout $myBranch
git commit -am "my message"
git push
which does update the file in my branch, however, since I'm making a commit and pushing, this triggers another build.

So, 2 questions:
1) Is there a better approach to versioning in Jenkins? From Googling, it looks like this is something that is done, but it looks like people use the Git Publisher plugin with the post-build action which doesn't seem available for pipelines(?) only freestyle.

2) If 1 is a good approach, how do I stop the infinite build loop?

Methanar
Sep 26, 2013

by the sex ghost
Your Jenkins pipeline is incrementing a version file?

It sounds sort of like this may be something better handled by a pre-commit hook before a branch is pushed up, rather than doing it in jenkins.
If semvers are not required, you could also consider having the version be the latest git sha of the commit Jenkins is acting on, which frees you from any sort of state maintaining of builds which came earlier.

If you really want Jenkins to do this intermediary step, I suppose what you could do is have the version-incremented branch have a specific naming pattern like `jenkins/<something>` and then make sure your pipeline triggers has a regex excluding your `jenkins/.*` branch pattern. That would solve the duplicate pipeline situation. But this all still feels really hacky.
Does the version file need to be actually in git, can it just be somehow an artifact independent of source control?

But maybe I'm misunderstanding the problem statement.

Methanar fucked around with this message at 23:32 on Jun 10, 2022

sausage king of Chicago
Jun 13, 2001

Methanar posted:

Your Jenkins pipeline is incrementing a version file?

It sounds sort of like this may be something better handled by a pre-commit hook before a branch is pushed up, rather than doing it in jenkins.
If semvers are not required, you could also consider having the version be the latest git sha of the commit Jenkins is acting on, which frees you from any sort of state maintaining of builds which came earlier.

If you really want Jenkins to do this intermediary step, I suppose what you could do is have the version-incremented branch have a specific naming pattern like `jenkins/<something>` and then make sure your pipeline triggers has a regex excluding your `jenkins/.*` branch pattern. That would solve the duplicate pipeline situation. But this all still feels really hacky.
Does the version file need to be actually in git, can it just be somehow an artifact independent of source control?

But maybe I'm misunderstanding the problem statement.

No, you got it right. I just started on a new team and they're using Jenkins, and this is the pipeline they have, but it's not working, so I'm trying to fix it.

There is a Version.json file like the one I posted above. Whenever a build of master is made, Jenkins runs a bash script that updates the version number. All of that is working, it's just getting the new version file into source is where I'm having the issue.

I just tried using a pre-commit hook, but it looks like that won't work either.

My hook looks like this:

#bash
filePath='./src/PathToMyFile/Version.json'
jq '.Minor += 1' "$filePath" > "$filePath.tmp" && cp "$filePath.tmp" "$filePath"
rm "$filePath.tmp"

so that updates the Version.json file fine, but then my branch is dirty because the hook made a modification to my file, if that makes sense.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Methanar posted:

Your Jenkins pipeline is incrementing a version file?

It sounds sort of like this may be something better handled by a pre-commit hook before a branch is pushed up, rather than doing it in jenkins.
If semvers are not required, you could also consider having the version be the latest git sha of the commit Jenkins is acting on, which frees you from any sort of state maintaining of builds which came earlier.

If you really want Jenkins to do this intermediary step, I suppose what you could do is have the version-incremented branch have a specific naming pattern like `jenkins/<something>` and then make sure your pipeline triggers has a regex excluding your `jenkins/.*` branch pattern. That would solve the duplicate pipeline situation. But this all still feels really hacky.
Does the version file need to be actually in git, can it just be somehow an artifact independent of source control?

But maybe I'm misunderstanding the problem statement.

I like to implement gitversion and let that drive the semver versioning. Just let it do its thing and force major version increments as necessary.

Methanar
Sep 26, 2013

by the sex ghost

sausage king of Chicago posted:

No, you got it right. I just started on a new team and they're using Jenkins, and this is the pipeline they have, but it's not working, so I'm trying to fix it.

There is a Version.json file like the one I posted above. Whenever a build of master is made, Jenkins runs a bash script that updates the version number. All of that is working, it's just getting the new version file into source is where I'm having the issue.

I just tried using a pre-commit hook, but it looks like that won't work either.

My hook looks like this:

#bash
filePath='./src/PathToMyFile/Version.json'
jq '.Minor += 1' "$filePath" > "$filePath.tmp" && cp "$filePath.tmp" "$filePath"
rm "$filePath.tmp"

so that updates the Version.json file fine, but then my branch is dirty because the hook made a modification to my file, if that makes sense.

Maybe commit --amend instead of a regular commit?

What if, instead:

When everyone pushes to master you execute your pipeline. Your pipeline then is adding your version file changes, and does a commit and push to a main branch. At this point everyone continues to work as normal with master being the target of their pull requests. It's just that your build artifacts are produced by a main branch where Jenkins curates the difference between master and main. It should be possible to set up filtering and workflow steps to then target the different branches as necessary.

I'm still of the opinion it feels seriously gross to be having Jenkins manipulating git on a branch that's already been pushed up and just asking for trouble. I've never heard of a workflow like this.

Methanar fucked around with this message at 01:11 on Jun 11, 2022

sausage king of Chicago
Jun 13, 2001

Methanar posted:

I'm still of the opinion it feels seriously gross to be having Jenkins manipulating git on a branch that's already been pushed up and just asking for trouble. I've never heard of a workflow like this.

Yeah, I agree, but that's just what I'm working with here, unfortunately. I've never really used Jenkins before last week, so I'm still trying to figure everything out.

I was just playing around with the pre-commit, and figured out that if I add in a 'git add Version.json' at the end, it works. However, thinking about it a bit more, that wouldn't be helpful in my use case since we only want the version updated when there is a build on the master branch, so, that sucks.

I guess I'll keep Googling around, but man, it loving sucks that this is such a struggle.

sausage king of Chicago fucked around with this message at 01:35 on Jun 11, 2022

The Fool
Oct 16, 2003


we push auto generated changelogs directly to master

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Methanar posted:


I'm still of the opinion it feels seriously gross to be having Jenkins manipulating git on a branch that's already been pushed up and just asking for trouble. I've never heard of a workflow like this.

It's awful and TONS of companies do it. I'll repeat myself: use gitversion. So many places jump through crazy hoops to implement semver when there's a great off the shelf tool that makes it super straightforward and can be configured to do whatever ridiculous bastardization of semver you use.

Vanadium
Jan 8, 2005

I would simply not update Version.json if I got invoked by a commit that updated Version.json

Red Mike
Jul 11, 2011
This is one of those very common awful practices that almost every company "trying to go devops" starts off doing. It's fine to not have a great process set up at that point so long as: the new process works reliably, and it doesn't lock you out of doing it the right way later. That is, unless you were brought in specifically to fix this, have the appropriate authority and permissions to basically force everyone onto a new processes (or isolate them from it), and have at least one other person actively working to train the rest of the staff and prevent them from "working around your awful new process".

The simplest solution that I'm aware of for Jenkins (that doesn't lock you out of fixing it later) is to have a keyword in the commit message that can skip automatic builds like "#nobuild". Set up the pipeline so that a commit message with that keyword just stops. Then try and stop the other developers from pushing half-written code and using the keyword to stop Jenkins complaining, until you actually implement something like gitversion.

Warbird
May 23, 2012

America's Favorite Dumbass

Can Jenkins env variables be set from within a shell execution block within a stage? I was looking to pass some info out from an env prep stage to the actual meat and potatoes portion of the pipeline but I’ve been unable to sort out of it can’t be done or I’m just doing it wrong. I’ve been able to work around it by just storing what I need in a file that get generated as part of the prep process but I’d be interested in hearing if that’s doable.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Warbird posted:

Can Jenkins env variables be set from within a shell execution block within a stage? I was looking to pass some info out from an env prep stage to the actual meat and potatoes portion of the pipeline but I’ve been unable to sort out of it can’t be done or I’m just doing it wrong. I’ve been able to work around it by just storing what I need in a file that get generated as part of the prep process but I’d be interested in hearing if that’s doable.

Yes but they don't persist between shell blocks.

Warbird
May 23, 2012

America's Favorite Dumbass

Ok that confirms my suspicions, thanks.

LochNessMonster
Feb 3, 2005

I need about three fitty


Blinkz0rz posted:

Yes but they don't persist between shell blocks.

Not by default but wasn’t there a way to do so?

It’s been a few years since I had to touch Jenkins so I could be misremembering.

E,f,b: quick google confirmed I’m misremembering…

LochNessMonster fucked around with this message at 21:17 on Jun 11, 2022

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

LochNessMonster posted:

Not by default but wasn’t there a way to do so?

It’s been a few years since I had to touch Jenkins so I could be misremembering.

Don't think so. From memory each shell step is launched in a separate shell. There is an environment variables step that is injected into every shell step but I don't think you can do anything dynamic with it.

LochNessMonster
Feb 3, 2005

I need about three fitty


Blinkz0rz posted:

Don't think so. From memory each shell step is launched in a separate shell. There is an environment variables step that is injected into every shell step but I don't think you can do anything dynamic with it.

You’re right, you can only set them on agent level (or global which makes them availble for every pipeline).

For passing variables between stages (or even different shell steps) writing to files seems to be your best option indeed.

Warbird
May 23, 2012

America's Favorite Dumbass

Love a good seemingly kludged solution that ends up being the “right” way to do things. Would would be a reasonable approach to setting up a key value pair to store in that file and retrieve values? Right now I’m just working with a sole value so that’s just a simple cat, but I could easily see situations where you’d want to cram umpteen values in there and call them accordingly. Of course you could do more files but that seems less than ideal.

Methanar
Sep 26, 2013

by the sex ghost

Warbird posted:

Love a good seemingly kludged solution that ends up being the “right” way to do things. Would would be a reasonable approach to setting up a key value pair to store in that file and retrieve values? Right now I’m just working with a sole value so that’s just a simple cat, but I could easily see situations where you’d want to cram umpteen values in there and call them accordingly. Of course you could do more files but that seems less than ideal.

write your values to a file. and then in a new stage source the file into your shell and access the key values as env variables

jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Put together a simple crud site and wget the values.

Warbird
May 23, 2012

America's Favorite Dumbass

Interesting. Got a link to some documentation or an example or two?

Edit - More the file sourcing and whatnot but the CRUD thing sounds like that could be fun.

The Fool
Oct 16, 2003


ado lets you set pipeline variables that are available from every task, does jenkins not have that

Methanar
Sep 26, 2013

by the sex ghost

Warbird posted:

Interesting. Got a link to some documentation or an example or two?

Edit - More the file sourcing and whatnot but the CRUD thing sounds like that could be fun.

code:
rm env
echo 'export key1=value1' >> env
echo 'export key2=value2' >> env
export $(cat env | xargs)
printenv | grep key

key2=value2
key1=value1

jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Warbird posted:

Interesting. Got a link to some documentation or an example or two?

Edit - More the file sourcing and whatnot but the CRUD thing sounds like that could be fun.

wget file, source ./file values are set.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

The Fool posted:

ado lets you set pipeline variables that are available from every task, does jenkins not have that

I'm ready to murder the person who designed the yaml pipeline implementation in Azure devops. The implementation variable scoping and resolution is impossible to debug and does a lot of PHP style "on error, silently do the wrong thing" behaviors.

Need to access the branch name of the repo containing the yaml? No problem. That's a compile time variable and can be freely used in template expressions so you can drive behavior and variable values based on that.

Need the branch name of a dependent repository resource? Sorry, that's a runtime variable and can't be accessed in compile time template expressions nor can it be used in conditional expressions, so enjoy making three copies of the same yaml to implement different behavior for PR vs debug vs release builds.

A variable resolves to blank because you tried to access it and it doesn't exist in the context you're trying to use it? Okay, the eq function will try to evaluate it as a bool, fail, and return false as a default instead of giving an error.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

New Yorp New Yorp posted:

I'm ready to murder the person who designed the yaml pipeline implementation in Azure devops. The implementation variable scoping and resolution is impossible to debug and does a lot of PHP style "on error, silently do the wrong thing" behaviors.

Need to access the branch name of the repo containing the yaml? No problem. That's a compile time variable and can be freely used in template expressions so you can drive behavior and variable values based on that.

Need the branch name of a dependent repository resource? Sorry, that's a runtime variable and can't be accessed in compile time template expressions nor can it be used in conditional expressions, so enjoy making three copies of the same yaml to implement different behavior for PR vs debug vs release builds.

A variable resolves to blank because you tried to access it and it doesn't exist in the context you're trying to use it? Okay, the eq function will try to evaluate it as a bool, fail, and return false as a default instead of giving an error.

This is giving me Chef flashbacks and I hate it.

Methanar
Sep 26, 2013

by the sex ghost
I'm so sick of bullshit yaml DSLs

Warbird
May 23, 2012

America's Favorite Dumbass

jaegerx posted:

wget file, source ./file values are set.

And it just pulls them in as env variables and so forth? Huh, that’s pretty neat.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
Let's not forget that you can always use envsubst in a pinch to do some variable substitution

Hadlock
Nov 9, 2004

What % of infra projects are "I don't feel a sense of ownership about this, so I'm rewriting this", vs "how did the previous guy manage to come up with such a hosed up implementation, God, it's going to be faster to rewrite the old poo poo, than try and shoehorn my stuff into this disaster"

Methanar
Sep 26, 2013

by the sex ghost

Hadlock posted:

What % of infra projects are "I don't feel a sense of ownership about this, so I'm rewriting this", vs "how did the previous guy manage to come up with such a hosed up implementation, God, it's going to be faster to rewrite the old poo poo, than try and shoehorn my stuff into this disaster"

don't @ me

LochNessMonster
Feb 3, 2005

I need about three fitty


Hadlock posted:

What % of infra projects are "I don't feel a sense of ownership about this, so I'm rewriting this", vs "how did the previous guy manage to come up with such a hosed up implementation, God, it's going to be faster to rewrite the old poo poo, than try and shoehorn my stuff into this disaster"

50% of these moments results in looking at the git hostory and going “of course I know him, he’s me”.

Docjowles
Apr 9, 2009

My old coworker was the first one. Every loving project he was assigned to, if it wasn’t totally greenfield development, his first step was “well this is all total poo poo and has to be rewritten from scratch”. We ended up with so much bespoke halfassed ruby crap (he was a die hard ruby shill) that only he understood in crucial places where a well known open source tool would have done the job. Or was doing the job, and got replaced for reasons he could not articulate beyond “it sucks”. He and my former boss who didn’t stomp this behavior out were a real blast to work with.

Adbot
ADBOT LOVES YOU

Happiness Commando
Feb 1, 2002
$$ joy at gunpoint $$

Pair programming with a colleague of mine knowing full well that the answer to my question "god drat it what rear end in a top hat wrote this" is "me"

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply