Friday, March 6, 2020

Jenkins, BitBucket and Pipeline

https://bitbucket.goweekend.ca/scm/devo/jenkins_pipeline.git

# ps -ef|grep jenkins
jenkins   5483     1  0 Feb10 ?        01:31:33 /var/lib/jenkins/jre/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -Djavax.net.ssl.trustStore=/var/lib/jenkins/.keystore/cacerts -Djavax.net.ssl.trustStorePassword=changeit -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 --httpsKeyStore=/var/lib/jenkins/jre/lib/security/castore --httpsKeyStorePassword=changeit -Dhudson.model.DirectoryBrowserSupport.CSP=


Running in /opt/build/weekend
[Pipeline] {
[Pipeline] pwd
[Pipeline] echo
Workspace dir is /opt/build/weekend
[Pipeline] checkout
using credential Jenkins
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://bitbucket.goweekend.ca/scm/weekend/weekend.git # timeout=10
Pruning obsolete local branches
Fetching upstream changes from https://bitbucket.goweekend.ca/scm/weekend/weekend.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Jenkins Builder
Setting http proxy: proxy.goweekend.ca:8888
 > git fetch --tags --progress https://bitbucket.goweekend.ca/scm/weekend/weekend.git +refs/heads/*:refs/remotes/origin/* --prune
 > git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision y9c2d5162964b694f7472ccc81685705bcdccae4 (origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f y9c2d5162964b694f7472ccc81685705bcdccae4
Commit message: "Merge pull request #140 in weekend/weekend from feature/GAP-1160 to develop"
 > git rev-list --no-walk 86fa7e2023616b1813cd63e4be7e01912c082bfe # timeout=10


git rev-parse is an ancillary plumbing command primarily used for manipulation.

One common usage of git rev-parse is to print the SHA1 hashes given a revision specifier. In addition, it has various options to format this output such as --short for printing a shorter unique SHA1.

There are other use cases as well (in scripts and other tools built on top of git) that I've used for:

--verify to verify that the specified object is a valid git object.
--git-dir for displaying the abs/relative path of the the .git directory.
Checking if you're currently within a repository using --is-inside-git-dir or within a work-tree using --is-inside-work-tree
Checking if the repo is a bare using --is-bare-repository
Printing SHA1 hashes of branches (--branches), tags (--tags) and the refs can also be filtered based on the remote (using --remote)
--parse-opt to normalize arguments in a script (kind of similar to getopt) and print an output string that can be used with eval
Massage just implies that it is possible to convert the info from one form into another i.e. a transformation command. These are some quick examples I can think of:

a branch or tag name into the commit's SHA1 it is pointing to so that it can be passed to a plumbing command which only accepts SHA1 values for the commit.
a revision range A..B for git log or git diff into the equivalent arguments for the underlying plumbing command as B ^A


https://sysadmin@bitbucket.goweekend.ca/scm/weekend/weekend.git



 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://bitbucket.goweekend.ca/scm/weekend/weekend.git # timeout=10
Pruning obsolete local branches
Fetching upstream changes from https://bitbucket.goweekend.ca/scm/weekend/weekend.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Jenkins Builder
Setting http proxy: proxy.goweekend.ca:8888
 > git fetch --tags --progress https://bitbucket.goweekend.ca/scm/weekend/weekend.git +refs/heads/*:refs/remotes/origin/* --prune
 > git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision b9c2d5162964b694f7472ccc81685705bcdccae4 (origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f b9c2d5162964b694f7472ccc81685705bcdccae4
Commit message: "Merge pull request #140 in weekend/weekend from feature/GAP-1160 to develop"
 > git rev-list --no-walk 96fa7e2023616b1813cd63e4be7e01912c082bfe # timeout=10
[Pipeline] step


git init

git config remote.origin.url  https://bitbucket.goweekend.ca/scm/iu/ithelpdesk.git

git fetch --tags --progress https://bitbucket.goweekend.ca/scm/iu/ithelpdesk.git +refs/heads/*:refs/remotes/origin/* --prune
git rev-parse origin/master^{commit}
git checkout -f 4feb053f9696122de7215969b4c3d1a3f67f7f44

No comments:

Post a Comment