简体   繁体   中英

How to get Jenkins to push to GitHub but not trigger a build off that push

The Setup

I've got a Mac mini set up with Jenkins pulling a repo down from GitHub and performing an Xcode build. Because the mini is firewalled off from the internet I am polling GitHub for changes every 15 minutes.

Prior to kicking off the Xcode build I have Jenkins execute the following script to bump my project build number and commit the results to the repo:

#!/bin/sh

agvtool bump -all
/usr/local/git/bin/git commit -a -m "This is Jenkins, updating your build numbers, sir."

After the build I have a post-build action set up to run another script that pulls and then pushes from GitHub, like so:

#!/bin/sh

/usr/local/git/bin/git pull origin develop
/usr/local/git/bin/git push origin develop

The Problem

Because Jenkins is performing a commit and a push to GitHub each time it runs, the next poll will find the changes it pushed up last time, creating a new build whether there were other actual changes or not.

The Question

Is there something wonky in my setup that I should be doing differently? I'd like Jenkins to update my Xcode target's build number and commit and push that result to GitHub. This configuration obviously accomplishes that, but with the side effect of a build every 15 minutes, instead of a build every 15 minutes as needed.

Jenkins is consulting the SHA1 of the lastSuccessfulBuild to determine if there have been changes, but it's doing that before my commit. Is there a way to set the SHA1 of the current build to the hash resulting from the commit of the version number bump? Something like so:

#!/bin/sh

agvtool bump -all
/usr/local/git/bin/git commit -a -m "This is Jenkins, updating your build numbers, sir."
NEW_SHA=$(/usr/local/git/bin/git rev-parse HEAD)
# Some awesome Jenkins-fu to set the SHA1 of the current build to NEW_SHA

This way when Jenkins compares hashes the next time around it won't build unless there have been changes since its commit to bump version numbers.

Thanks for any and all help.

I think this SO question answers your question, but I can't say for certain as we're not doing build version increment on a polling branch. I would also do the git push prior to building, that way you won't have to worry about as many merges that would occur should you commit code things during the build. Thankfully, if you keep it how it is you won't have much to worry about in the way of Xcode project merges.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM