Skip to content

Commit

Permalink
Feature/jenkins slave python build (#345)
Browse files Browse the repository at this point in the history
* jenkins-slave-python - add pr and publish jobs

* jenkins-slaves/jenkins-slave-python/Dockerfile - update to upgrade pip to latest
  • Loading branch information
itewk authored May 17, 2020
1 parent 40e7d85 commit e5079ad
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/jenkins-agent-python-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: jenkins-agent-python-pr
on:
pull_request:
paths:
- jenkins-slaves/jenkins-slave-python/**
jobs:
build:
env:
context: jenkins-slaves/jenkins-slave-python
image_name: jenkins-agent-python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check and verify version.json
id: check_version
run: |
echo -n ::set-output name=IMAGE_TAGS::
echo $(jq -r '.version' ${context}/version.json)
- name: Build image
uses: docker/build-push-action@v1
with:
path: ${{ env.context }}
push: false
repository: ${{ env.image_name }}
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}
- name: Test image
run: |
echo "Running: docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version"
docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version
echo "Running: docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} pip --version"
docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} pip --version
39 changes: 39 additions & 0 deletions .github/workflows/jenkins-agent-python-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: jenkins-agent-python-publish
on:
push:
branches:
- master
tags:
- '*'
paths:
- jenkins-slaves/jenkins-slave-python/version.json
jobs:
build:
env:
context: jenkins-slaves/jenkins-slave-python
image_name: jenkins-agent-python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
VERSION=$(jq -r '.version' ${context}/version.json)
TAGS=('latest')
if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then
TAGS+=("${VERSION}")
fi
if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then
TAGS+=("git-${BASH_REMATCH[1]}")
fi
( IFS=$','; echo "${TAGS[*]}" )
- name: Build and publish image to Quay
uses: docker/build-push-action@v1
with:
path: ${{ env.context }}
registry: ${{ secrets.REGISTRY_URI }}
repository: ${{ secrets.REGISTRY_REPOSITORY }}/${{ env.image_name }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
tags: "${{ steps.image_tags.outputs.IMAGE_TAGS }}"
1 change: 1 addition & 0 deletions jenkins-slaves/jenkins-slave-python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN INSTALL_PKGS=" \
yum -y clean all --enablerepo='*' && \
source scl_source enable rh-python36 && \
scl enable rh-python36 bash && \
python3 -m pip install --upgrade pip && \
python3 -m pip install twine

ADD scl_enable /usr/share/container-scripts/
Expand Down
1 change: 1 addition & 0 deletions jenkins-slaves/jenkins-slave-python/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"v1.0"}

0 comments on commit e5079ad

Please sign in to comment.