-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] initiall version of PR build jobs #8
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
Open
dahorak
wants to merge
27
commits into
Tendrl:master
Choose a base branch
from
dahorak:pr-build-jobs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6608161
initiall version of PR build jobs
dahorak 5a063ad
PR builds: email notifications send-to-individuals
dahorak 342980f
stop the job in case of any failure
dahorak baccc21
workaround inconsistency in Makefile targets
dahorak d2619c7
fix indentation
dahorak 5f5479f
pr builds: cleanup source packages
dahorak 37f2a45
pr-builds: set timeout to 40 minutes
dahorak 5a40751
pr-build: remove PR_VARIANT from branch name
dahorak 13f09f0
pr-builds: cleanup
dahorak 7224873
pr-build: add "package build to" status-context
dahorak ec8a886
pr-builds: notify also sds-mgmt-dev list
dahorak b6dff30
rename tendrl-build-triggers-pr.yml
dahorak b03bceb
pr-builds: cleanup config
dahorak 8b57ae2
pr-builds: allow build for members of Tendrl org
dahorak a5d3328
pr-builds: disable send-to-individuals
dahorak ae65e08
pr-builds: specify branches to origin/pr/**
dahorak 3024914
pr-builds: add "99" before release string
dahorak 5040281
pr-builds: separate admin and white-listed people
dahorak d68eb11
pr-builds: build localy using mock instead of Copr
dahorak 5d2cd7f
pr-builds: use master branch for merged PRs
dahorak c55546b
pr-builds: unify make gitversion target
dahorak 937fae7
pr-builds: yamllint fix (remove trailing spaces)
dahorak d4bb5db
pr-builds: log last 5 git commits
dahorak 61fb637
pr-builds: use more clear git hash for release
dahorak 12278a2
pr-builds: disable gpgcheck
dahorak a7e5ac4
remove sds-mgmt-dev@redhat.com list
dahorak 5ea1e38
pr-build-jobs: add verbosity (-v) to mock
dahorak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
283 changes: 283 additions & 0 deletions
283
jobs/build-triggers/tendrl-build-triggers-pr-builds.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,283 @@ | ||
| --- | ||
| - job-template: | ||
| name: "tendrl-build-1-pr-{package_name}" | ||
| display-name: 'Tendrl build: ({project_name}) - {package_name}' | ||
| description: | | ||
| <b>Job building Tendrl package '{package_name}' from PR | ||
| and pushing it to '{target_repo}' repo.</b><br> | ||
| Maintainer: <a href="mailto:dahorak@redhat.com">Daniel Horak</a><br> | ||
| Team Contact: <a href="mailto:tendrl-devel@redhat.com">tendrl-devel</a><br><br> | ||
| JJB Code Location: <a href="https://github.com/Tendrl/tendrl-ci/tree/master/jobs">tendrl-ci</a><br> | ||
| Managed by Jenkins Job Builder. Do not edit via web.<br> | ||
| project-type: freestyle | ||
| copr_config: '~/.config/copr' | ||
| package_prefix: "tendrl-" | ||
| defaults: global | ||
| disabled: false | ||
| concurrent: false | ||
| quiet-period: 0 | ||
| block-downstream: false | ||
| block-upstream: false | ||
| node: 'tendrl-ci-slave01' | ||
| triggers: "{obj:triggers}" | ||
| scm: "{obj:scm}" | ||
| properties: | ||
| - github: | ||
| url: 'https://github.com/Tendrl/{package_name}/' | ||
| wrappers: | ||
| - timeout: | ||
| timeout: 40 | ||
| abort: true | ||
| type: absolute | ||
| parameters: | ||
| - string: | ||
| name: TARGET_REPO | ||
| default: "{target_repo}" | ||
| description: "Target copr repo name." | ||
| builders: | ||
| - shell: | | ||
| echo "GIT_COMMIT: ${{GIT_COMMIT}}" | ||
| echo "GIT_BRANCH: ${{GIT_BRANCH}}" | ||
| echo "TARGET_REPO: ${{TARGET_REPO}}" | ||
| # prepare unique identifier for this build (BUILD_HASH) | ||
| export BUILD_HASH=$(mktemp -du "build-{target_repo}-{package_prefix}{package_name}.XXXXXXXXXX") | ||
| echo "BUILD_HASH=${{BUILD_HASH}}" > ${{WORKSPACE}}/env.sh | ||
| # "reserve" build server for this job | ||
| echo "${{BUILD_HASH}}" >> ${{HOME}}/build_server_{project_name}_used_by | ||
|
|
||
| # prepare building server (if not already reserved) | ||
| - conditional-step: | ||
| condition-kind: shell | ||
| condition-command: "(( $(grep -v '^ *$' $HOME/build_server_{project_name}_status | wc -l) == 0))" | ||
| on-evaluation-failure: dont-run | ||
| steps: | ||
| - trigger-builds: | ||
| - project: 'tendrl-build-X-build_server-{project_name}-prepare' | ||
| block: true | ||
| property-file: env.sh | ||
|
|
||
| - shell: | | ||
| #!/bin/bash -xe | ||
| # load environment file with BUILD_HASH | ||
| source ${{WORKSPACE}}/env.sh | ||
| echo "GIT_COMMIT: ${{GIT_COMMIT}}" | ||
| echo "GIT_BRANCH: ${{GIT_BRANCH}}" | ||
| # parse PR# and head/merge variant | ||
| if [[ "${{ghprbPullId}}" ]]; then | ||
| PR_NUMBER=${{ghprbPullId}} | ||
| PR_VARIANT="merge" | ||
| else | ||
| PR_NUMBER=$(echo $GIT_BRANCH | awk -F / '{{ print $3 }}') | ||
| PR_VARIANT=$(echo $GIT_BRANCH | awk -F / '{{ print $4 }}') | ||
| fi | ||
| echo "PR_NUMBER: ${{PR_NUMBER}}" | ||
| echo "PR_VARIANT: ${{PR_VARIANT}}" | ||
| echo "ghprbPullId: ${{ghprbPullId}}" | ||
|
|
||
| # wait for build_server to be ready | ||
| until grep -q "READY" ${{HOME}}/build_server_{project_name}_status; do | ||
| sleep 10 | ||
| done | ||
|
|
||
| # remote working directory | ||
| rwd="/tmp/${{BUILD_HASH}}" | ||
| # get build server hostname | ||
| build_server=$(grep -A1 '\[build_server\]' ${{HOME}}/build_server_{project_name}.hosts | tail -1) | ||
| # check if build_server is available. | ||
| ssh root@${{build_server}} "hostname" | ||
| # prepare remote working directory | ||
| ssh root@${{build_server}} "mkdir ${{rwd}}" | ||
|
|
||
| # clone git repository with source code | ||
| ssh root@${{build_server}} \ | ||
| "git clone https://github.com/Tendrl/{package_name} ${{rwd}}/{package_name}" | ||
|
|
||
| # prepare refs, use master if it is for closed PR | ||
| refs="refs/pull/${{PR_NUMBER}}/${{PR_VARIANT}}" | ||
| if [[ "${{ghprbActualCommitAuthorEmail}}" == "noreply@github.com" ]]; then | ||
| refs="master" | ||
| fi | ||
| # fetch and checkout the PR branch | ||
| branch="pr${{PR_NUMBER}}" | ||
| ssh root@${{build_server}} \ | ||
| "set -xe; \ | ||
| cd ${{rwd}}/{package_name}; \ | ||
| git fetch origin ${{refs}}:${{branch}}; \ | ||
| git checkout ${{branch}}; \ | ||
| git log -5; \ | ||
| git status;" | ||
|
|
||
| # prepare git hash based release string | ||
| # - for not merged PR, it will contain two hashes for both | ||
| # parents of the temporary merge to master commit | ||
| # - for merged PR, it will contain only the hash of the merge commit | ||
| # (or last commit from master) | ||
| git_commit_and_parrents=$(ssh root@${{build_server}} \ | ||
| "set -xe; \ | ||
| cd ${{rwd}}/{package_name}; \ | ||
| git rev-list --parents -n 1 HEAD") | ||
| git_last_commit=$(echo "${{git_commit_and_parrents}}" | awk '{{ print $1 }}' | cut -c1-7 ) | ||
| if [[ "${{ghprbActualCommitAuthorEmail}}" == "noreply@github.com" ]]; then | ||
| git_hash_release_string="${{git_last_commit}}" | ||
| else | ||
| git_parrent_a=$(echo "${{git_commit_and_parrents}}" | awk '{{ print $2 }}' | cut -c1-7 ) | ||
| git_parrent_b=$(echo "${{git_commit_and_parrents}}" | awk '{{ print $3 }}' | cut -c1-7 ) | ||
| git_hash_release_string="${{git_parrent_a}}_${{git_parrent_b}}" | ||
| fi | ||
| echo "${{git_last_commit}}" | ||
| echo "${{git_hash_release_string}}" | ||
|
|
||
| # build srpm package | ||
| ssh root@${{build_server}} \ | ||
| "set -xe; \ | ||
| cd ${{rwd}}/{package_name}; \ | ||
| make gitversion ;\ | ||
| sed -i \"s/\(^Release:.*\)/\1.${{branch}}/\" {package_prefix}{package_name}.spec ;\ | ||
| sed -i \"s/\(^Release: *\)/\199/\" {package_prefix}{package_name}.spec ;\ | ||
| sed -i \"s/${{git_last_commit}}/${{git_hash_release_string}}/\" {package_prefix}{package_name}.spec ;\ | ||
| make srpm ;\ | ||
| ls -l;" | ||
|
|
||
| # prepare mock configuration | ||
| mock_root="/var/lib/mock/epel-7-x86_64-${{BUILD_HASH}}" | ||
| mock_cfg="${{rwd}}/mock-epel-7-x86_64.cfg" | ||
| ssh root@${{build_server}} \ | ||
| "set -xe; \ | ||
| cp /etc/mock/epel-7-x86_64.cfg ${{mock_cfg}}; \ | ||
| sed -i 's/epel-7-x86_64/epel-7-x86_64-${{BUILD_HASH}}/' ${{mock_cfg}}" | ||
|
|
||
| # build RPM packages using mock | ||
| ssh root@${{build_server}} \ | ||
| "set -xe; \ | ||
| mock -v -r ${{mock_cfg}} rebuild \ | ||
| ${{rwd}}/{package_name}/{package_prefix}{package_name}*.src.rpm" | ||
|
|
||
| # prepare RPM repo | ||
| ssh root@${{build_server}} \ | ||
| "set -xe; \ | ||
| mkdir -p ${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}}; \ | ||
| cp ${{mock_root}}/result/*.rpm ${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}};" | ||
|
|
||
| # cleanup the repo | ||
| ssh root@${{build_server}} \ | ||
| "find ${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}} \ | ||
| -type f ! -iname '*.rpm' -delete" | ||
| ssh root@${{build_server}} \ | ||
| "find ${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}} \ | ||
| -type f -iname '*.src.rpm' -delete" | ||
|
|
||
| # prepare rpm repo | ||
| ssh root@${{build_server}} \ | ||
| "createrepo ${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}}/" | ||
|
|
||
| # prepare repofile | ||
| repo_file="${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}}/{package_prefix}{package_name}-${{branch}}.repo" | ||
| ssh root@${{build_server}} \ | ||
| "echo '[{package_prefix}{package_name}-${{branch}}]' > ${{repo_file}} ;\ | ||
| echo 'name={package_prefix}{package_name}-${{branch}}' >> ${{repo_file}} ;\ | ||
| echo 'baseurl=http://artifacts.ci.centos.org/tendrl/pr/{package_prefix}{package_name}/${{branch}}/' >> ${{repo_file}} ;\ | ||
| echo 'skip_if_unavailable=True' >> ${{repo_file}} ;\ | ||
| echo 'gpgcheck=0' >> ${{repo_file}} ;\ | ||
| echo 'gpgkey=https://copr-be.cloud.fedoraproject.org/results/tendrl/${{TARGET_REPO}}/pubkey.gpg' >> ${{repo_file}} ;\ | ||
| echo 'repo_gpgcheck=0' >> ${{repo_file}} ;\ | ||
| echo 'enabled=1' >> ${{repo_file}} ;\ | ||
| echo '' >> ${{repo_file}};" | ||
|
|
||
| # upload generated repo to artifacts.ci.centos.org | ||
| set +x | ||
| key=$(cat ~/duffy.key) | ||
| ssh root@${{build_server}} \ | ||
| "RSYNC_PASSWORD=${{key:0:13}} rsync -av \ | ||
| ${{rwd}}/rpms/pr/ \ | ||
| tendrl@artifacts.ci.centos.org::tendrl/pr/" | ||
| # cleanup older packages for the particular PR | ||
| ssh root@${{build_server}} \ | ||
| "RSYNC_PASSWORD=${{key:0:13}} rsync -av --delete \ | ||
| ${{rwd}}/rpms/pr/{package_prefix}{package_name}/${{branch}}/ \ | ||
| tendrl@artifacts.ci.centos.org::tendrl/pr/{package_prefix}{package_name}/${{branch}}/" | ||
| set +x | ||
|
|
||
| echo | ||
| echo "##############################################################" | ||
| echo "REPO: http://artifacts.ci.centos.org/tendrl/pr/{package_prefix}{package_name}/${{branch}}/{package_prefix}{package_name}-${{branch}}.repo" | ||
| echo "##############################################################" | ||
| echo | ||
|
|
||
| publishers: | ||
| - trigger-parameterized-builds: | ||
| - project: 'tendrl-build-X-build_server-{project_name}-teardown' | ||
| property-file: env.sh | ||
| condition: ALWAYS | ||
|
|
||
| - email: | ||
| recipients: dahorak@redhat.com | ||
| send-to-individuals: false | ||
|
|
||
|
|
||
| - project: | ||
| name: 'PR' | ||
| project_name: 'PR' | ||
| target_repo: 'Features' | ||
| copr_config: '~/.copr-tendrl.conf' | ||
| copr_user: 'tendrl' | ||
| triggers: | ||
| - github-pull-request: | ||
| admin-list: | ||
| - dahorak | ||
| white-list: | ||
| - a2batic | ||
| - cloudbehl | ||
| - fbalak | ||
| - gnehapk | ||
| - GowthamShanmugam | ||
| - julienlim | ||
| - ktdreyer | ||
| - ltrilety | ||
| - mbukatov | ||
| - mcarrano | ||
| - nnDarshan | ||
| - nthomas-redhat | ||
| - r0h4n | ||
| - rishubhjain | ||
| - sankarshanmukhopadhyay | ||
| - scuttlemonkey | ||
| - shirshendu | ||
| - shtripat | ||
| - sidhax | ||
| - tigert | ||
| - TimothyAsir | ||
| - TimothyAsirJeyasing | ||
| org-list: | ||
| - Tendrl | ||
| allow-whitelist-orgs-as-admins: false | ||
| trigger-phrase: '.*run build.*' | ||
| skip-build-phrase: 'no build' | ||
| github-hooks: true | ||
| cancel-builds-on-update: true | ||
| status-context: 'CentOS CI - package build' | ||
| status-add-test-results: false | ||
| scm: | ||
| - git: | ||
| url: 'https://github.com/Tendrl/{package_name}' | ||
| refspec: "+refs/pull/${{ghprbPullId}}/*:refs/remotes/origin/pr/${{ghprbPullId}}/*" | ||
| branches: | ||
| - "origin/pr/**" | ||
| basedir: tendrl-{package_name} | ||
| skip-tag: true | ||
| wipe-workspace: true | ||
| jobs: | ||
| - "tendrl-build-1-pr-{package_name}" | ||
| - "tendrl-build-X-build_server-{project_name}-prepare" | ||
| - "tendrl-build-X-build_server-{project_name}-teardown" | ||
| package_name: | ||
| - api | ||
| - commons | ||
| - gluster-integration | ||
| - monitoring-integration | ||
| - node-agent | ||
| - notifier | ||
| - tendrl-ansible: | ||
| package_prefix: "" | ||
| - tendrl-selinux: | ||
| package_prefix: "" | ||
| - ui | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to input this rather than hardcoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nthomas-redhat it should be possible, to automatically fetch the list of people from the organization specified below in the
org-listsection, but there seems to be some problem with this and I'm not sure why it doesn't work and where might be the problem with that.I'll try to check that once more and find some more information about that - that will be definitely the best solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nthomas-redhat I've found partial solution for this: it works for people with Public membership.
@r0h4n could you please check, if centos-ci user is part of Tendrl organization?
That might solve the problem with people with private membership in Tendrl org.
(I know, you already added it #6 (comment), but it seems like it is not there https://github.com/orgs/Tendrl/people...)