You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.6 KiB

pipeline {
agent {
label 'cico-workspace'
parameters {
string(name: 'REPO', defaultValue: '', description: 'Git repo URL where the pull request from')
string(name: 'BRANCH', defaultValue: '', description: 'Git branch where the pull request from')
stages {
stage('CI') {
steps {
script {
if (params.REPO == "" || params.BRANCH == "") {
error "Please supply both params (REPO and BRANCH)"
try {
echo "Requesting duffy node ..."
def session_str = sh returnStdout: true, script: "set +x; duffy client --url --auth-name fedora-infra --auth-key $CICO_API_KEY request-session pool=virt-ec2-t2-centos-9s-x86_64,quantity=1"
def session = readJSON text: session_str
def hostname = session.session.nodes[0].hostname
echo "duffy session id: $DUFFY_SESSION_ID hostname: $hostname"
def remote_dir = "/tmp/$JENKINS_AGENT_NAME"
echo "remote_dir: $remote_dir"
writeFile file: '', text: """
set -xe
dnf install -y git podman
git config --global "jenkins@localhost"
git config --global "jenkins"
cd $remote_dir
git clone -b master
cd pungi
git remote rm proposed || true
git remote add proposed "$params.REPO"
git fetch proposed
git checkout origin/master
git merge --no-ff "proposed/$params.BRANCH" -m "Merge PR"
podman run --rm -v .:/src:Z tox -r -e flake8,black,py3,bandit
podman run --rm -v .:/src:Z tox -r -e py27
sh "cat"
sh "ssh -o StrictHostKeyChecking=no root@$hostname mkdir $remote_dir"
sh "scp root@$hostname:$remote_dir"
sh "ssh root@$hostname sh $remote_dir/"
} finally {
echo "Release duffy node ..."
sh "set +x; duffy client --url --auth-name fedora-infra --auth-key $CICO_API_KEY retire-session $DUFFY_SESSION_ID > /dev/null"